JuliaPlots / UnicodePlots.jl

Unicode-based scientific plotting for working in the terminal
Other
1.45k stars 82 forks source link

Unitful extension errors when x-axis has units and y-axis does not #383

Closed adamslc closed 4 weeks ago

adamslc commented 2 months ago
julia> using Unitful, UnicodePlots

julia> lineplot(rand(1), rand(1) * u"m"); # works

julia> lineplot(rand(1) * u"m", rand(1))  # errors
ERROR: DimensionError: 0.6949985300147672 m and 1.0 are not dimensionally compatible.
Stacktrace:
 [1] -(x::Quantity{Float64, š‹, Unitful.FreeUnits{(m,), š‹, nothing}}, y::Quantity{Float64, NoDims, Unitful.FreeUnits{(), NoDims, nothing}}
)
   @ Unitful ~/.julia/packages/Unitful/GYzMo/src/quantities.jl:137
 [2] -(x::Quantity{Float64, š‹, Unitful.FreeUnits{(m,), š‹, nothing}}, y::Int64)
   @ Base ./promotion.jl:424
 [3] extend_limits(vec::Vector{Quantity{Float64, š‹, Unitful.FreeUnits{(m,), š‹, nothing}}}, lims::Tuple{Int64, Int64}, scale::typeof(ident
ity))
   @ UnicodePlots ~/.julia/packages/UnicodePlots/DYDL5/src/common.jl:449
 [4] Plot(x::Vector{ā€¦}, y::Vector{ā€¦}, z::Nothing, canvas::Type{ā€¦}; title::String, xlabel::String, ylabel::String, zlabel::String, unicode
_exponent::Bool, thousands_separator::Char, xscale::Symbol, yscale::Symbol, height::Nothing, width::Nothing, border::Symbol, compact::Boo
l, blend::Bool, xlim::Tuple{ā€¦}, ylim::Tuple{ā€¦}, margin::Int64, padding::Int64, labels::Bool, colorbar::Bool, colorbar_border::Symbol, col
orbar_lim::Tuple{ā€¦}, colormap::Symbol, grid::Bool, yticks::Bool, xticks::Bool, min_height::Int64, min_width::Int64, yflip::Bool, xflip::B
ool, projection::Nothing, axes3d::Bool, canvas_kw::@NamedTuple{}, kw::@Kwargs{})
   @ UnicodePlots ~/.julia/packages/UnicodePlots/DYDL5/src/plot.jl:224
 [5] Plot(x::Vector{Quantity{Float64, š‹, Unitful.FreeUnits{(m,), š‹, nothing}}}, y::Vector{Float64}, z::Nothing, canvas::Type{BrailleCanva
s})
   @ UnicodePlots ~/.julia/packages/UnicodePlots/DYDL5/src/plot.jl:154
 [6] lineplot(x::Vector{Quantity{Float64, š‹, Unitful.FreeUnits{ā€¦}}}, y::Vector{Float64}, z::Nothing; canvas::Type, kw::@Kwargs{})
   @ UnicodePlots ~/.julia/packages/UnicodePlots/DYDL5/src/interface/lineplot.jl:77
 [7] lineplot
   @ ~/.julia/packages/UnicodePlots/DYDL5/src/interface/lineplot.jl:69 [inlined]
 [8] lineplot(x::Vector{Quantity{Float64, š‹, Unitful.FreeUnits{(m,), š‹, nothing}}}, y::Vector{Float64})
   @ UnicodePlots ~/.julia/packages/UnicodePlots/DYDL5/src/interface/lineplot.jl:69
 [9] top-level scope
   @ REPL[12]:1
Some type information was truncated. Use `show(err)` to see complete types.