Hi All,
Ramping up on Julia, so forgive any naivety
Iβm hitting an error when trying to plot a function in a unitful way:
julia> using Unitful, UnitfulRecipes, Plots
julia> """
The Severinghaus Oxygen Dissociation Curve
http://www-users.med.cornell.edu/~spon/picu/calc/o2satcal.htm
"""
severinghaus(ppO2) = (23400 * (ppO2^3 + 150 * ppO2)^-1 + 1)^-1
severinghaus
julia> """
The Severinghaus Oxygen Dissociation Curve, but with units
http://www-users.med.cornell.edu/~spon/picu/calc/o2satcal.htm
"""
function severinghaus(ppO2::Unitful.Pressure)
ppO2 = Unitful.uconvert(u"Torr", ppO2)
sat = (23400 * (ppO2^3 + 150 * ppO2)^-1 + 1)^-1
end
severinghaus
julia> plot(severinghaus, xlims=(1,150))
**pretty graph**
julia> plot(severinghaus, xlims=(1u"Torr",150u"Torr"))
ERROR: MethodError: no method matching adapted_grid(::Base.var"#62#63"{Base.var"#62#63"{RecipesPipeline.var"#11#12"{Symbol},typeof(severinghaus)},RecipesPipeline.var"#13#14"{Symbol}}, ::Tuple{Quantity{Float64,π π^-1 π^-2,Unitful.FreeUnits{(Torr,),π π^-1 π^-2,nothing}},Quantity{Float64,π π^-1 π^-2,Unitful.FreeUnits{(Torr,),π π^-1 π^-2,nothing}}})
Closest candidates are:
adapted_grid(::Any, ::Tuple{Real,Real}; max_recursions) at /home/aatif/.julia/packages/PlotUtils/3Ttrk/src/adapted_grid.jl:14
Stacktrace:
[1] _scaled_adapted_grid(::Function, ::Symbol, ::Symbol, ::Quantity{Int64,π π^-1 π^-2,Unitful.FreeUnits{(Torr,),π π^-1 π^-2,nothing}}, ::Quantity{Int64,π π^-1 π^-2,Unitful.FreeUnits{(Torr,),π π^-1 π^-2,nothing}}) at /home/aatif/.julia/packages/RecipesPipeline/tkFmN/src/user_recipe.jl:307
[2] macro expansion at /home/aatif/.julia/packages/RecipesPipeline/tkFmN/src/user_recipe.jl:286 [inlined]
[3] apply_recipe(::Dict{Symbol,Any}, ::Function, ::Quantity{Int64,π π^-1 π^-2,Unitful.FreeUnits{(Torr,),π π^-1 π^-2,nothing}}, ::Quantity{Int64,π π^-1 π^-2,Unitful.FreeUnits{(Torr,),π π^-1 π^-2,nothing}}) at /home/aatif/.julia/packages/RecipesBase/aQmWx/src/RecipesBase.jl:281
[4] _process_userrecipes!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{typeof(severinghaus)}) at /home/aatif/.julia/packages/RecipesPipeline/tkFmN/src/user_recipe.jl:35
[5] recipe_pipeline!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{typeof(severinghaus)}) at /home/aatif/.julia/packages/RecipesPipeline/tkFmN/src/RecipesPipeline.jl:69
[6] _plot!(::Plots.Plot{Plots.GRBackend}, ::Dict{Symbol,Any}, ::Tuple{typeof(severinghaus)}) at /home/aatif/.julia/packages/Plots/5K6Ue/src/plot.jl:167
[7] plot(::Function; kw::Base.Iterators.Pairs{Symbol,Tuple{Quantity{Int64,π π^-1 π^-2,Unitful.FreeUnits{(Torr,),π π^-1 π^-2,nothing}},Quantity{Int64,π π^-1 π^-2,Unitful.FreeUnits{(Torr,),π π^-1 π^-2,nothing}}},Tuple{Symbol},NamedTuple{(:xlims,),Tuple{Tuple{Quantity{Int64,π π^-1 π^-2,Unitful.FreeUnits{(Torr,),π π^-1 π^-2,nothing}},Quantity{Int64,π π^-1 π^-2,Unitful.FreeUnits{(Torr,),π π^-1 π^-2,nothing}}}}}}) at /home/aatif/.julia/packages/Plots/5K6Ue/src/plot.jl:57
[8] top-level scope at REPL[5]:1
Iβve attempted using Unitful.ustrip
at various places in severinghaus
, to no avail - am I trying to do something unsupported? Are there simple changes that I can make to either my code or a package that can get this working?
Thank you for any advice