PainterQubits / UnitfulPlots.jl

Plots with unit labels, automatically
Other
9 stars 4 forks source link

Does not plot vectors of #4

Open ChrisRackauckas opened 8 years ago

ChrisRackauckas commented 8 years ago

Might want to get @tbreloff in on this one. The recipe found here https://github.com/JuliaDiffEq/DifferentialEquations.jl/blob/master/src/general/plotrecipes.jl#L39 can be simplified in this case to the following:

@recipe function f(sol::AbstractODESolution;plot_analytic=false,denseplot=true,plotdensity=100)
  plotseries = Vector{Any}(0)
  plot_timeseries = sol.timeseries
  push!(plotseries,plot_timeseries)
  plott = sol.t
  plott, plotseries
end

This fails (presumably because Plots cannot handle the units?)

MethodError: no method matching isless(::Float64, ::Unitful.Quantity{Float64,Unitful.Dimensions{(Unitful.Dimension{:Time}(1//1),)},Unitful.Units{(Unitful.Unit{:Second}(0,1//1),),Unitful.Dimensions{(Unitful.Dimension{:Time}(1//1),)}}})
Closest candidates are:
  isless(::Float64, !Matched::Float64) at float.jl:415
  isless(::AbstractFloat, !Matched::AbstractFloat) at operators.jl:75
  isless(::Real, !Matched::AbstractFloat) at operators.jl:76
  ...
 in expand_extrema!(::Plots.Extrema, ::Unitful.Quantity{Float64,Unitful.Dimensions{(Unitful.Dimension{:Time}(1//1),)},Unitful.Units{(Unitful.Unit{:Second}(0,1//1),),Unitful.Dimensions{(Unitful.Dimension{:Time}(1//1),)}}}) at C:\Users\Chris\.julia\v0.6\Plots\src\axes.jl:239
 in expand_extrema!(::Plots.Axis, ::Array{Quantity{Float64, Dimensions:{𝐓}, Units:{s}},1}) at C:\Users\Chris\.julia\v0.6\Plots\src\axes.jl:262
 in expand_extrema!(::Plots.Subplot{Plots.PlotlyBackend}, ::Dict{Symbol,Any}) at C:\Users\Chris\.julia\v0.6\Plots\src\axes.jl:289...

Plotting the two parts works:

plot(sol.t,sol[:])

but the moment I put the y axis part into any kind of a vector, it fails with that same error:

plot(sol.t,[sol[:]])
plot(sol.t,Any[sol[:]])