working on unicodeplots
This commit is contained in:
parent
426a9eb6d3
commit
9e1058ec0a
@ -54,14 +54,9 @@ end
|
|||||||
# add a single series
|
# add a single series
|
||||||
function addUnicodeSeries!(o, d::Dict, addlegend::Bool)
|
function addUnicodeSeries!(o, d::Dict, addlegend::Bool)
|
||||||
|
|
||||||
|
# get the function, or special handling for step/bar/hist
|
||||||
lt = d[:linetype]
|
lt = d[:linetype]
|
||||||
x, y = [collect(float(d[s])) for s in (:x, :y)]
|
|
||||||
label = addlegend ? d[:label] : ""
|
|
||||||
stepstyle = :post
|
stepstyle = :post
|
||||||
|
|
||||||
# if we happen to pass in allowed color symbols, great... otherwise let UnicodePlots decide
|
|
||||||
color = d[:color] in UnicodePlots.autoColors ? d[:color] : :auto
|
|
||||||
|
|
||||||
if lt == :line
|
if lt == :line
|
||||||
func = UnicodePlots.lineplot!
|
func = UnicodePlots.lineplot!
|
||||||
elseif lt == :dots || d[:marker] != :none
|
elseif lt == :dots || d[:marker] != :none
|
||||||
@ -71,10 +66,24 @@ function addUnicodeSeries!(o, d::Dict, addlegend::Bool)
|
|||||||
elseif lt == :stepinverted
|
elseif lt == :stepinverted
|
||||||
func = UnicodePlots.stairs!
|
func = UnicodePlots.stairs!
|
||||||
stepstyle = :pre
|
stepstyle = :pre
|
||||||
|
# elseif lt in (:sticks, :bar)
|
||||||
|
# d = barHack(; d...)
|
||||||
|
# func = UnicodePlots.lineplot!
|
||||||
|
# elseif lt == :hist
|
||||||
|
# d = histogramHack(; d...)
|
||||||
|
# func = UnicodePlots.lineplot!
|
||||||
else
|
else
|
||||||
error("Linestyle $lt not supported by UnicodePlots")
|
error("Linestyle $lt not supported by UnicodePlots")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# get the series data and label
|
||||||
|
x, y = [collect(float(d[s])) for s in (:x, :y)]
|
||||||
|
label = addlegend ? d[:label] : ""
|
||||||
|
|
||||||
|
# if we happen to pass in allowed color symbols, great... otherwise let UnicodePlots decide
|
||||||
|
color = d[:color] in UnicodePlots.autoColors ? d[:color] : :auto
|
||||||
|
|
||||||
|
# add the series
|
||||||
func(o, x, y; color = color, name = label, style = stepstyle)
|
func(o, x, y; color = color, name = label, style = stepstyle)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -95,7 +104,13 @@ function plot(pkg::UnicodePlotsPackage; kw...)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function plot!(::UnicodePlotsPackage, plt::Plot; kw...)
|
function plot!(::UnicodePlotsPackage, plt::Plot; kw...)
|
||||||
push!(plt.seriesargs, Dict(kw))
|
d = Dict(kw)
|
||||||
|
if d[:linetype] in (:sticks, :bar)
|
||||||
|
d = barHack(; d...)
|
||||||
|
elseif d[:linetype] == :hist
|
||||||
|
d = barHack(; histogramHack(; d...)...)
|
||||||
|
end
|
||||||
|
push!(plt.seriesargs, d)
|
||||||
plt
|
plt
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user