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

Plotting matrices (multiple lines) #7

Open
Cody-G opened this issue Jun 16, 2017 · 2 comments
Open

Plotting matrices (multiple lines) #7

Cody-G opened this issue Jun 16, 2017 · 2 comments

Comments

@Cody-G
Copy link

Cody-G commented Jun 16, 2017

Plotting multiple line plots by passing a matrix of Quantities fails. Here's a demo and the error message

using Plots, UnitfulPlots
plotlyjs()
import Unitful: μm

a = rand(100)
a_um = a * μm

plot([a_um a_um]) #fails
plot([a a]) #succeeds
ERROR: DimensionError: Inf and 0.8797156427357942 μm are not dimensionally compatible.
 in expand_extrema!(::Plots.Extrema, ::Unitful.Quantity{Float64,Unitful.Dimensions{(Unitful.Dimension{:Length}(1//1),)},Unitful.FreeUnits{(Unitful.Unit{:Meter,Unitful.Dimensions{(Unitful.Dimension{:Length}(1//1),)}}(-6,1//1),),Unitful.Dimensions{(Unitful.Dimension{:Length}(1//1),)}}}) at /home/cody/.julia/v0.5/Plots/src/axes.jl:239
 in expand_extrema!(::Plots.Axis, ::Array{Quantity{Float64, Dimensions:{𝐋}, Units:{μm}},1}) at /home/cody/.julia/v0.5/Plots/src/axes.jl:262
 in expand_extrema!(::Plots.Subplot{Plots.PlotlyJSBackend}, ::Dict{Symbol,Any}) at /home/cody/.julia/v0.5/Plots/src/axes.jl:289
 in _expand_subplot_extrema(::Plots.Subplot{Plots.PlotlyJSBackend}, ::Dict{Symbol,Any}, ::Symbol) at /home/cody/.julia/v0.5/Plots/src/pipeline.jl:361
 in _process_seriesrecipe(::Plots.Plot{Plots.PlotlyJSBackend}, ::Dict{Symbol,Any}) at /home/cody/.julia/v0.5/Plots/src/pipeline.jl:392
 in _plot!(::Plots.Plot{Plots.PlotlyJSBackend}, ::Dict{Symbol,Any}, ::Tuple{Array{Quantity{Float64, Dimensions:{𝐋}, Units:{μm}},2}}) at /home/cody/.julia/v0.5/Plots/src/plot.jl:227
 in plot(::Array{Quantity{Float64, Dimensions:{𝐋}, Units:{μm}},2}) at /home/cody/.julia/v0.5/Plots/src/plot.jl:46
@Cody-G
Copy link
Author

Cody-G commented Jun 16, 2017

I assume that I can fix this by adding another recipe? I haven't used RecipesBase before but I will look into how to do that.

@ajkeller34
Copy link
Collaborator

You might be able to fix this with a recipe, but if not you'll need to write a method Plots.expand_extrema!(::Plots.Extrema, ::Unitful.Quantity). In the method Plots.expand_extrema!(::Plots.Extrema, ::Number) there appears to be some comparison being done in a dimensionally unsound way since Plots.Extrema has Float64 fields. The fix is probably going to be pretty ugly until Plots.jl itself becomes dimensionally aware, I'd guess.

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

No branches or pull requests

2 participants