Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move warning about plotlybase png rendering to error #4733

Merged
merged 4 commits into from
Apr 28, 2023

Conversation

fonsp
Copy link
Contributor

@fonsp fonsp commented Apr 27, 2023

Before this PR, you would always see a warning about rendering to png when using the plotly backend.

Scherm­afbeelding 2023-04-27 om 22 01 06

Not so nice, and confusing for many users!

An easy improvement would be to change this to @info, but in this PR, I used the super powerful Base.Experimental.register_error_hint feature to move this "warning" to when it becomes relevant: when you try to render to png!

After this PR, the warning message is gone when calling plotly(), and it magically appears in the error message!

julia> using Plots

julia> plotly()
Plots.PlotlyBackend()

julia> p = plot(1:10);

julia> repr(MIME"image/png"(), p)
ERROR: MethodError: no method matching _show(::IOBuffer, ::MIME{Symbol("image/png")}, ::Plots.Plot{Plots.PlotlyBackend})

Tip: For saving/rendering as png with the `Plotly` backend `PlotlyBase` and `PlotlyKaleido` need to be installed.

Closest candidates are:
  _show(::IO, ::MIME{Symbol("image/png")}, ::Plots.Plot{Plots.GRBackend}) at ~/.julia/packages/Plots/etZYh/src/backends/gr.jl:2041
  _show(::IO, ::MIME{Symbol("application/vnd.plotly.v1+json")}, ::Plots.Plot{Plots.PlotlyBackend}) at ~/.julia/packages/Plots/etZYh/src/backends/plotly.jl:1131
  _show(::IO, ::MIME{Symbol("text/html")}, ::Plots.Plot{Plots.PlotlyBackend}) at ~/.julia/packages/Plots/etZYh/src/backends/plotly.jl:1134
  ...
Stacktrace:
...

julia> 

@codecov
Copy link

codecov bot commented Apr 27, 2023

Codecov Report

Patch coverage: 33.33% and project coverage change: -0.01 ⚠️

Comparison is base (97a72fd) 90.35% compared to head (2faa57d) 90.34%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #4733      +/-   ##
==========================================
- Coverage   90.35%   90.34%   -0.01%     
==========================================
  Files          40       40              
  Lines        8731     8733       +2     
==========================================
+ Hits         7889     7890       +1     
- Misses        842      843       +1     
Impacted Files Coverage Δ
src/backends.jl 82.26% <33.33%> (-0.33%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@t-bltg t-bltg merged commit 349eea4 into JuliaPlots:master Apr 28, 2023
@t-bltg
Copy link
Member

t-bltg commented Apr 28, 2023

Thanks, nicely explained !

@fonsp fonsp deleted the patch-3 branch May 16, 2023 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants