-
-
Notifications
You must be signed in to change notification settings - Fork 358
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
[BUG] Crash on annotate with Unitful #4366
Comments
Thanks for the report. I have slightly different results, so this might have to do with floating point numerics. julia> using Unitful, Plots; unicodeplots()
julia> plot([0,1]u"s", [0,2]u"m")
ERROR: DimensionError: Inf and 0.0 s are not dimensionally compatible.
Stacktrace:
[1] _isless
@ [...]/Unitful/ApCuY/src/quantities.jl:272 [inlined]
[2] isless(x::Quantity{Float64, NoDims, Unitful.FreeUnits{(), NoDims, nothing}}, y::Quantity{Float64, 𝐓, Unitful.FreeUnits{(s,), 𝐓, nothing}})
@ Unitful [...]/Unitful/ApCuY/src/quantities.jl:262
[3] isless(x::Float64, y::Quantity{Float64, 𝐓, Unitful.FreeUnits{(s,), 𝐓, nothing}})
@ Unitful [...]/Unitful/ApCuY/src/quantities.jl:264
[4] min(x::Quantity{Float64, 𝐓, Unitful.FreeUnits{(s,), 𝐓, nothing}}, y::Float64)
@ Base ./operators.jl:494
[5] expand_extrema!(ex::Plots.Extrema, v::Quantity{Float64, 𝐓, Unitful.FreeUnits{(s,), 𝐓, nothing}})
@ Plots [...]/Plots.jl/src/axes.jl:407
[6] expand_extrema!(axis::Plots.Axis, v::Vector{Quantity{Float64, 𝐓, Unitful.FreeUnits{(s,), 𝐓, nothing}}})
@ Plots [...]/Plots.jl/src/axes.jl:427
[7] expand_extrema!(sp::Plots.Subplot{Plots.UnicodePlotsBackend}, plotattributes::RecipesPipeline.DefaultsDict)
@ Plots [...]/Plots.jl/src/axes.jl:462
[8] _expand_subplot_extrema(sp::Plots.Subplot{Plots.UnicodePlotsBackend}, plotattributes::RecipesPipeline.DefaultsDict, st::Symbol)
@ Plots [...]/Plots.jl/src/pipeline.jl:421
[9] add_series!(plt::Plots.Plot{Plots.UnicodePlotsBackend}, plotattributes::RecipesPipeline.DefaultsDict)
@ Plots [...]/Plots.jl/src/pipeline.jl:364
[10] _process_seriesrecipe(plt::Any, plotattributes::Any)
@ RecipesPipeline [...]/RecipesPipeline/OXGmH/src/series_recipe.jl:46
[11] _process_seriesrecipes!(plt::Any, kw_list::Any)
@ RecipesPipeline [...]/RecipesPipeline/OXGmH/src/series_recipe.jl:27
[12] recipe_pipeline!(plt::Any, plotattributes::Any, args::Any)
@ RecipesPipeline [...]/RecipesPipeline/OXGmH/src/RecipesPipeline.jl:97
[13] _plot!(plt::Plots.Plot, plotattributes::Any, args::Any)
@ Plots [...]/Plots.jl/src/plot.jl:232
[14] plot(::Any, ::Vararg{Any}; kw::Base.Pairs{Symbol, V, Tuple{Vararg{Symbol, N}}, NamedTuple{names, T}} where {V, N, names, T<:Tuple{Vararg{Any, N}}})
@ Plots [...]/Plots.jl/src/plot.jl:107
[15] plot(::Any, ::Any)
@ Plots [...]/Plots.jl/src/plot.jl:98
[16] top-level scope
@ REPL[15]:1 |
Related: PainterQubits/Unitful.jl#455. The "fix" is to use julia> using Unitful, UnitfulRecipes, Plots; unicodeplots()
julia> plot([0,1]u"s", [0,2]u"m")
┌────────────────────────────────────────┐
2.06 │⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠤⠀│ y1
│⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠒⠁⠀⠀│
│⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠔⠉⠀⠀⠀⠀⠀│
│⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠤⠊⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠒⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠔⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠤⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
m │⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠒⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⠔⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⠤⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⡇⠀⠀⠀⠀⠀⠀⠀⠀⠀⡠⠒⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⡇⠀⠀⠀⠀⠀⠀⣀⠔⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⡇⠀⠀⠀⢀⠤⠊⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
│⠀⡇⠀⡠⠒⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀│
-0.06 │⠤⡷⠭⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤⠤│
└────────────────────────────────────────┘
⠀-0.03⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀s⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀1.03⠀
|
That might be one reason to do #4114, actually we could just load it via Requires.jl. |
Something like that in https://github.com/JuliaPlots/Plots.jl/blob/master/src/init.jl ? @require Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" begin
include("<the code contained in module `UnitfulRecipes`>")
using .UnitfulRecipes
end Looks feasible, since you need It depends if @jw3126 would be in favor of archiving / deprecating |
We wouldn't neccessarily need to move the code. We could also do something like @require Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d" begin
try
@eval Main using UnitfulRecipes
catch
@warn "Plotting unitful quantities requires to have UnitfulRecipes installed."
end
end |
Won't this imply that each time your are loading |
Maybe |
Even |
Pardon, I was not entirely clear about the situation. It happens with UnitfulRecipes and I have problem with Here's the full snippet to recreate behaviour using Plots, PGFPlotsX, Plotly, PlotlyJS, InspectDR, UnicodePlots
using Unitful, UnitfulRecipes
gr() # or other backends I mentioned
Plots.plot([0,1]u"s", [0,1]u"m") # it works on all backends with UnitfulRecipes
Plots.annotate!([0.25]u"s", [0.5]u"m", text("annotation"))
|
If you have |
Sure I am open to moving UnitfulRecipes.jl into Plots.jl. |
Details
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. 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.5s,1m)Not sure if it belongs here, Unitful or UnitfulRecipes though. Or if I should split the report per backend.
GR stacktrace:
UnicodePlots:
Can upload stacktraces of PGFPlotsX and InspectDR if needed.
Backends
This bug occurs on ( insert
x
below )Versions
Plots.jl version: 1.33.0
Backend version:
Output of
versioninfo()
:The text was updated successfully, but these errors were encountered: