Closed schneiderfelipe closed 3 years ago
Yes, I don't think there is a recipe for
plot(f, xmin, xmax)
What does
plot(I_blackbody, 100, 3000, label=5000u"K")
give you?
Side note: I don't think the plot(f, xmin, xmax)
case qualifies as "parametric". I think the parametric equivalent would be plot(identity, f, xmin, xmax)
(but maybe that's what the former dispatches on in the pipeline?).
What does
plot(I_blackbody, 100, 3000, label=5000u"K")
give you?
That throws a specific error in the I_blackbody
function, as it only accepts Quantity
objects (something along ERROR: MethodError: no method matching exp(::Quantity{Int64,π,Unitful.FreeUnits{(nm,),π,nothing}})
).
I think we can fix this with a PR changing Real
to T where {T<:Number}
in this line of PlotUtils.jl (seemed to work locally for me)
@jw3126 any thoughts?
@briochemc sure sounds fine to me.
@schneiderfelipe I think it should work now if you update your environment (a new version of PlotUtils β with the fix β was released) π
@briochemc Thanks for the change! But I might be doing something wrong. The following works:
plot(Ξ» -> Ξ», 100, 6000)
But the following one still doesn't:
plot(Ξ» -> Ξ», 100u"nm", 6000u"nm")
DimensionError: Inf and 100.0 nm are not dimensionally compatible.
_isless@quantities.jl:274[inlined]
isless(::Unitful.Quantity{Float64,NoDims,Unitful.FreeUnits{(),NoDims,nothing}}, ::Unitful.Quantity{Float64,π,Unitful.FreeUnits{(nm,),π,nothing}})@quantities.jl:264
isless(::Float64, ::Unitful.Quantity{Float64,π,Unitful.FreeUnits{(nm,),π,nothing}})@quantities.jl:266
min(::Unitful.Quantity{Float64,π,Unitful.FreeUnits{(nm,),π,nothing}}, ::Float64)@operators.jl:422
expand_extrema!@axes.jl:311[inlined]
expand_extrema!(::Plots.Axis, ::Array{Unitful.Quantity{Float64,π,Unitful.FreeUnits{(nm,),π,nothing}},1})@axes.jl:334
expand_extrema!(::Plots.Subplot{Plots.GRBackend}, ::RecipesPipeline.DefaultsDict)@axes.jl:364
_expand_subplot_extrema(::Plots.Subplot{Plots.GRBackend}, ::RecipesPipeline.DefaultsDict, ::Symbol)@pipeline.jl:361
add_series!(::Plots.Plot{Plots.GRBackend}, ::RecipesPipeline.DefaultsDict)@pipeline.jl:312
_process_seriesrecipe(::Plots.Plot{Plots.GRBackend}, ::RecipesPipeline.DefaultsDict)@series_recipe.jl:44
_process_seriesrecipes!(::Plots.Plot{Plots.GRBackend}, ::Array{Dict{Symbol,Any},1})@series_recipe.jl:25
recipe_pipeline!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{Main.workspace51.var"#1#2",Unitful.Quantity{Int64,π,Unitful.FreeUnits{(nm,),π,nothing}},Unitful.Quantity{Int64,π,Unitful.FreeUnits{(nm,),π,nothing}}})@RecipesPipeline.jl:96
_plot!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{Main.workspace51.var"#1#2",Unitful.Quantity{Int64,π,Unitful.FreeUnits{(nm,),π,nothing}},Unitful.Quantity{Int64,π,Unitful.FreeUnits{(nm,),π,nothing}}})@plot.jl:167
#plot#129(::Base.Iterators.Pairs{Union{},Union{},Tuple{},NamedTuple{(),Tuple{}}}, ::typeof(RecipesBase.plot), ::Function, ::Vararg{Any,N} where N)@plot.jl:57
plot(::Function, ::Unitful.Quantity{Int64,π,Unitful.FreeUnits{(nm,),π,nothing}}, ::Vararg{Unitful.Quantity{Int64,π,Unitful.FreeUnits{(nm,),π,nothing}},N} where N)@plot.jl:51
top-level scope@Local: 1
I'm using PlotUtils v1.0.9 released yesterday:
(@v1.4) pkg> status PlotUtils
Status `~/.julia/environments/v1.4/Project.toml`
[995b91a9] PlotUtils v1.0.9
Can you share the notebook file, too?
This worked for me...
Are you sure you did not forget using UnitfulRecipes
?
Are you sure you did not forget
using UnitfulRecipes
?
You're right, I forgot to do exactly that!
This is not working for me (and I remembered to add using UnitfulRecipes
). Is this broken for other people by any chance?
@anojo what versions are you using?
@briochemc My bad! I was using v1.0.3 but some other package had me stuck at an older version of Unitful, and I imagine that's the reason it wasn't working. Now it does!
Hi @jw3126, I expected both examples below to yield the same result:
The first one works as expected (even though it lacks the natural LaTeX string in the y-axis, as I'm using
pyplot()
):The second example, on the other hand, throws an error:
Comparing this with the parametric example in the docs, I suspect this is due to the units of the start- and endpoints of the x-axis range (
3000u"nm"
, etc.). Is this expected?