UnitfulRecipes.jl icon indicating copy to clipboard operation
UnitfulRecipes.jl copied to clipboard

Crash on annotate

Open ivan-boikov opened this issue 1 year ago • 1 comments

Using annotate! with Unitful coordinates fails on GR, InspectDR, PGFPlotsX and UnicodePlots. On PlotlyJS no crash, but annotation ends up on top left corner of plot.

using Plots, PGFPlotsX, Plotly, PlotlyJS, InspectDR, UnicodePlots
using Unitful, UnitfulRecipes
gr() # or other backends
Plots.plot([0,1]u"s", [0,1]u"m")
Plots.annotate!([0.25]u"s", [0.5]u"m", text("annotation"))

Without units no crashes on all backends, but it is assumed that units are the same as in plot() call, i.e. here annotation will be at (0.25s,0.5m)

Plots.plot([0,1]u"s", [0,1]u"m")
Plots.annotate!([0.25], [0.5], text("annotation"))

GR stacktrace

ERROR: MethodError: no method matching wctondc(::Quantity{Float64, 𝐓, Unitful.FreeUnits{(s,), 𝐓, nothing}}, ::Quantity{Float64, 𝐋, Unitful.FreeUnits{(m,), 𝐋, nothing}})
Stacktrace:
[1] gr_display(sp::Plots.Subplot{Plots.GRBackend}, w::Measures.AbsoluteLength, h::Measures.AbsoluteLength, viewport_canvas::Vector{Float64}) 
    @ Plots ~/.local/share/julia/packages/Plots/FCUr0/src/backends/gr.jl:1050
[2] gr_display(plt::Plots.Plot{Plots.GRBackend}, fmt::String)
    @ Plots ~/.local/share/julia/packages/Plots/FCUr0/src/backends/gr.jl:699
[3] gr_display
    @ ~/.local/share/julia/packages/Plots/FCUr0/src/backends/gr.jl:665 [inlined]
[4] _display(plt::Plots.Plot{Plots.GRBackend}) 
    @ Plots ~/.local/share/julia/packages/Plots/FCUr0/src/backends/gr.jl:2250
[5] display(#unused#::Plots.PlotsDisplay, plt::Plots.Plot{Plots.GRBackend})
    @ Plots ~/.local/share/julia/packages/Plots/FCUr0/src/output.jl:164
[6] display(x::Any)
    @ Base.Multimedia ./multimedia.jl:328
[7] #invokelatest#2
    @ ./essentials.jl:729 [inlined]
[8] invokelatest
    @ ./essentials.jl:726 [inlined]
[9] print_response(errio::IO, response::Any, show_value::Bool, have_color::Bool, specialdisplay::Union{Nothing, AbstractDisplay})
    @ REPL ~/soft/julia-1.8.1/share/julia/stdlib/v1.8/REPL/src/REPL.jl:296
[10] (::REPL.var"#45#46"{REPL.LineEditREPL, Pair{Any, Bool}, Bool, Bool})(io::Any)
    @ REPL ~/soft/julia-1.8.1/share/julia/stdlib/v1.8/REPL/src/REPL.jl:278
[11] with_repl_linfo(f::Any, repl::REPL.LineEditREPL)
    @ REPL ~/soft/julia-1.8.1/share/julia/stdlib/v1.8/REPL/src/REPL.jl:521
[12] print_response(repl::REPL.AbstractREPL, response::Any, show_value::Bool, have_color::Bool)
    @ REPL ~/soft/julia-1.8.1/share/julia/stdlib/v1.8/REPL/src/REPL.jl:276
[13] (::REPL.var"#do_respond#66"{Bool, Bool, REPL.var"#77#87"{REPL.LineEditREPL, REPL.REPLHistoryProvider}, REPL.LineEditREPL, REPL.LineEdit.Prompt})(s::REPL.LineEdit.MIState, buf::Any, ok::Bool)
    @ REPL ~/soft/julia-1.8.1/share/julia/stdlib/v1.8/REPL/src/REPL.jl:857
[14] #invokelatest#2
    @ ./essentials.jl:729 [inlined]
[15] invokelatest
    @ ./essentials.jl:726 [inlined]
[16] run_interface(terminal::REPL.Terminals.TextTerminal, m::REPL.LineEdit.ModalInterface, s::REPL.LineEdit.MIState)
    @ REPL.LineEdit ~/soft/julia-1.8.1/share/julia/stdlib/v1.8/REPL/src/LineEdit.jl:2510
[17] run_frontend(repl::REPL.LineEditREPL, backend::REPL.REPLBackendRef)
    @ REPL ~/soft/julia-1.8.1/share/julia/stdlib/v1.8/REPL/src/REPL.jl:1248
[18] (::REPL.var"#49#54"{REPL.LineEditREPL, REPL.REPLBackendRef})()
    @ REPL ./task.jl:484

Julia v.1.8.1 Plots v.1.33.0 Unitful v.1.12.0 UnitfulRecipes v.1.6.0

ivan-boikov avatar Sep 24 '22 09:09 ivan-boikov