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

Gadfly can't plot Unitful.jl Quantities #1104

Closed
non-Jedi opened this issue Mar 16, 2018 · 1 comment
Closed

Gadfly can't plot Unitful.jl Quantities #1104

non-Jedi opened this issue Mar 16, 2018 · 1 comment

Comments

@non-Jedi
Copy link
Contributor

non-Jedi commented Mar 16, 2018

e.g.:

julia> using Gadfly; using Unitful;
 
julia> plot(x=[1;2;3]u"m/s", y=[1;2;3]u"s", Geom.line)
Error showing value of type Gadfly.Plot:
ERROR: DimensionError: s and 1 are not dimensionally compatible.
Stacktrace:
 [1] optimize_ticks_typed(::Unitful.Quantity{Int64,Unitful.Dimensions{(Unitful.Dimension{:Time}(1//1),)},Unitful.FreeUnits{(Unitful.Unit{:Second,Unitful.Dimensions{(Unitful.Dimension{:Time}(1//1),)}}(0, 1//1),),Unitful.Dimensions{(Unitful.Dimension{:Time}(1//1),)}}}, ::Unitful.Quantity{Int64,Unitful.Dimensions{(Unitful.Dimension{:Time}(1//1),)},Unitful.FreeUnits{(Unitful.Unit{:Second,Unitful.Dimensions{(Unitful.Dimension{:Time}(1//1),)}}(0, 1//1),),Unitful.Dimensions{(Unitful.Dimension{:Time}(1//1),)}}}, ::Bool, ::Array{Tuple{Float64,Float64},1}, ::Int64, ::Int64, ::Int64, ::Float64, ::Float64, ::Float64, ::Float64, ::Bool) at /home/adam/.julia/v0.6/Gadfly/src/ticks.jl:72
 [2] (::Gadfly.#kw##optimize_ticks)(::Array{Any,1}, ::Gadfly.#optimize_ticks, ::Unitful.Quantity{Int64,Unitful.Dimensions{(Unitful.Dimension{:Time}(1//1),)},Unitful.FreeUnits{(Unitful.Unit{:Second,Unitful.Dimensions{(Unitful.Dimension{:Time}(1//1),)}}(0, 1//1),),Unitful.Dimensions{(Unitful.Dimension{:Time}(1//1),)}}}, ::Unitful.Quantity{Int64,Unitful.Dimensions{(Unitful.Dimension{:Time}(1//1),)},Unitful.FreeUnits{(Unitful.Unit{:Second,Unitful.Dimensions{(Unitful.Dimension{:Time}(1//1),)}}(0, 1//1),),Unitful.Dimensions{(Unitful.Dimension{:Time}(1//1),)}}}) at ./<missing>:0
 [3] apply_statistic(::Gadfly.Stat.TickStatistic, ::Dict{Symbol,Gadfly.ScaleElement}, ::Gadfly.Coord.Cartesian, ::Gadfly.Aesthetics) at /home/adam/.julia/v0.6/Gadfly/src/statistics.jl:854
 [4] apply_statistics(::Array{Gadfly.StatisticElement,1}, ::Dict{Symbol,Gadfly.ScaleElement}, ::Gadfly.Coord.Cartesian, ::Gadfly.Aesthetics) at /home/adam/.julia/v0.6/Gadfly/src/statistics.jl:40
 [5] render_prepare(::Gadfly.Plot) at /home/adam/.julia/v0.6/Gadfly/src/Gadfly.jl:707
 [6] render(::Gadfly.Plot) at /home/adam/.julia/v0.6/Gadfly/src/Gadfly.jl:760
 [7] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::MIME{Symbol("text/html")}, ::Gadfly.Plot) at /home/adam/.julia/v0.6/Gadfly/src/Gadfly.jl:1074
 [8] display(::Base.REPL.REPLDisplay{Base.REPL.LineEditREPL}, ::Gadfly.Plot) at /home/adam/.julia/v0.6/Gadfly/src/Gadfly.jl:1019
 [9] display(::Gadfly.Plot) at ./multimedia.jl:194
 [10] eval(::Module, ::Any) at ./boot.jl:235
 [11] print_response(::Base.Terminals.TTYTerminal, ::Any, ::Void, ::Bool, ::Bool, ::Void) at ./REPL.jl:144
 [12] print_response(::Base.REPL.LineEditREPL, ::Any, ::Void, ::Bool, ::Bool) at ./REPL.jl:129
 [13] (::Base.REPL.#do_respond#16{Bool,Base.REPL.##26#36{Base.REPL.LineEditREPL,Base.REPL.REPLHistoryProvider},Base.REPL.LineEditREPL,Base.LineEdit.Prompt})(::Base.LineEdit.MIState, ::Base.AbstractIOBuffer{Array{UInt8,1}}, ::Bool) at ./REPL.jl:646

The problem I believe is here:

one_t = convert(T, one(T))

Instead of calling convert(T, one(T)), oneunit(T) should be called. May be other problems, but this is the first one.

@bjarthur
Copy link
Member

would be great to fix all of Gadfly's problems when used with Unitful. you are the first i know that have tried the two together. please let us know of other problems as they arise. fixing them all in a single PR would be best.

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