unicode hline/vline; supportGraph utils
This commit is contained in:
parent
518ccf5a74
commit
a0455561b6
File diff suppressed because one or more lines are too long
@ -296,7 +296,7 @@ function addGadflyTicksGuide(gplt, ticks, isx::Bool)
|
||||
end
|
||||
|
||||
# isContinuousScale(scale, isx::Bool) = isa(scale, Gadfly.Scale.ContinuousScale) && scale.vars[1] == (isx ? :x : :y)
|
||||
filterGadflyScale(gplt, isx::Bool) = filter!(scale -> scale.vars[1] == (isx ? :x : :y), gplt.scales)
|
||||
filterGadflyScale(gplt, isx::Bool) = filter!(scale -> scale.vars[1] != (isx ? :x : :y), gplt.scales)
|
||||
|
||||
function addGadflyLimitsScale(gplt, lims, isx::Bool)
|
||||
lims == :auto && return
|
||||
@ -345,6 +345,7 @@ function updateGadflyGuides(gplt, d::Dict)
|
||||
haskey(d, :title) && findGuideAndSet(gplt, Gadfly.Guide.title, d[:title])
|
||||
haskey(d, :xlabel) && findGuideAndSet(gplt, Gadfly.Guide.xlabel, d[:xlabel])
|
||||
haskey(d, :ylabel) && findGuideAndSet(gplt, Gadfly.Guide.ylabel, d[:ylabel])
|
||||
|
||||
haskey(d, :xlims) && addGadflyLimitsScale(gplt, d[:xlims], true)
|
||||
haskey(d, :ylims) && addGadflyLimitsScale(gplt, d[:ylims], false)
|
||||
haskey(d, :xticks) && addGadflyTicksGuide(gplt, d[:xticks], true)
|
||||
|
||||
@ -51,7 +51,7 @@ supportedArgs(::UnicodePlotsPackage) = [
|
||||
# :yticks,
|
||||
]
|
||||
supportedAxes(::UnicodePlotsPackage) = [:auto, :left]
|
||||
supportedTypes(::UnicodePlotsPackage) = [:none, :line, :path, :steppost, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar]
|
||||
supportedTypes(::UnicodePlotsPackage) = [:none, :line, :path, :steppost, :sticks, :scatter, :heatmap, :hexbin, :hist, :bar, :hline, :vline]
|
||||
supportedStyles(::UnicodePlotsPackage) = [:auto, :solid]
|
||||
supportedMarkers(::UnicodePlotsPackage) = [:none, :auto, :ellipse]
|
||||
|
||||
@ -112,7 +112,7 @@ function rebuildUnicodePlot!(plt::Plot)
|
||||
|
||||
# now use the ! functions to add to the plot
|
||||
for d in sargs
|
||||
addUnicodeSeries!(o, d, iargs[:legend])
|
||||
addUnicodeSeries!(o, d, iargs[:legend], xlim, ylim)
|
||||
end
|
||||
|
||||
# save the object
|
||||
@ -121,10 +121,23 @@ end
|
||||
|
||||
|
||||
# add a single series
|
||||
function addUnicodeSeries!(o, d::Dict, addlegend::Bool)
|
||||
function addUnicodeSeries!(o, d::Dict, addlegend::Bool, xlim, ylim)
|
||||
|
||||
# get the function, or special handling for step/bar/hist
|
||||
lt = d[:linetype]
|
||||
|
||||
# handle hline/vline separately
|
||||
if lt in (:hline,:vline)
|
||||
for yi in d[:y]
|
||||
if lt == :hline
|
||||
UnicodePlots.lineplot!(o, xlim, [yi,yi])
|
||||
else
|
||||
UnicodePlots.lineplot!(o, [yi,yi], ylim)
|
||||
end
|
||||
end
|
||||
return
|
||||
end
|
||||
|
||||
stepstyle = :post
|
||||
if lt == :path
|
||||
func = UnicodePlots.lineplot!
|
||||
|
||||
24
src/utils.jl
24
src/utils.jl
@ -209,6 +209,30 @@ extendSeriesData(v::AVec, z) = (push!(v, z); v)
|
||||
extendSeriesData(v::AVec, z::AVec) = (append!(v, z); v)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
function supportGraph(allvals, func)
|
||||
vals = reverse(allvals)
|
||||
x = ASCIIString[]
|
||||
y = ASCIIString[]
|
||||
for b in backends()
|
||||
supported = func(Plots.backendInstance(b))
|
||||
for val in vals
|
||||
if val in supported
|
||||
push!(x, string(b))
|
||||
push!(y, string(val))
|
||||
end
|
||||
end
|
||||
end
|
||||
scatter(x,y, m=:rect, ms=10, size=(300,100+18*length(vals)), leg=false)
|
||||
end
|
||||
|
||||
supportGraphArgs() = supportGraph(_allArgs, supportedArgs)
|
||||
supportGraphTypes() = supportGraph(_allTypes, supportedTypes)
|
||||
supportGraphStyles() = supportGraph(_allStyles, supportedStyles)
|
||||
supportGraphMarkers() = supportGraph(_allMarkers, supportedMarkers)
|
||||
supportGraphAxes() = supportGraph(_allAxes, supportedAxes)
|
||||
|
||||
# ---------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user