unicode hline/vline; supportGraph utils

This commit is contained in:
Thomas Breloff 2015-09-29 13:46:31 -04:00
parent 518ccf5a74
commit a0455561b6
4 changed files with 181 additions and 61 deletions

File diff suppressed because one or more lines are too long

View File

@ -296,7 +296,7 @@ function addGadflyTicksGuide(gplt, ticks, isx::Bool)
end end
# isContinuousScale(scale, isx::Bool) = isa(scale, Gadfly.Scale.ContinuousScale) && scale.vars[1] == (isx ? :x : :y) # 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) function addGadflyLimitsScale(gplt, lims, isx::Bool)
lims == :auto && return lims == :auto && return
@ -345,6 +345,7 @@ function updateGadflyGuides(gplt, d::Dict)
haskey(d, :title) && findGuideAndSet(gplt, Gadfly.Guide.title, d[:title]) haskey(d, :title) && findGuideAndSet(gplt, Gadfly.Guide.title, d[:title])
haskey(d, :xlabel) && findGuideAndSet(gplt, Gadfly.Guide.xlabel, d[:xlabel]) haskey(d, :xlabel) && findGuideAndSet(gplt, Gadfly.Guide.xlabel, d[:xlabel])
haskey(d, :ylabel) && findGuideAndSet(gplt, Gadfly.Guide.ylabel, d[:ylabel]) haskey(d, :ylabel) && findGuideAndSet(gplt, Gadfly.Guide.ylabel, d[:ylabel])
haskey(d, :xlims) && addGadflyLimitsScale(gplt, d[:xlims], true) haskey(d, :xlims) && addGadflyLimitsScale(gplt, d[:xlims], true)
haskey(d, :ylims) && addGadflyLimitsScale(gplt, d[:ylims], false) haskey(d, :ylims) && addGadflyLimitsScale(gplt, d[:ylims], false)
haskey(d, :xticks) && addGadflyTicksGuide(gplt, d[:xticks], true) haskey(d, :xticks) && addGadflyTicksGuide(gplt, d[:xticks], true)

View File

@ -51,7 +51,7 @@ supportedArgs(::UnicodePlotsPackage) = [
# :yticks, # :yticks,
] ]
supportedAxes(::UnicodePlotsPackage) = [:auto, :left] 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] supportedStyles(::UnicodePlotsPackage) = [:auto, :solid]
supportedMarkers(::UnicodePlotsPackage) = [:none, :auto, :ellipse] supportedMarkers(::UnicodePlotsPackage) = [:none, :auto, :ellipse]
@ -112,7 +112,7 @@ function rebuildUnicodePlot!(plt::Plot)
# now use the ! functions to add to the plot # now use the ! functions to add to the plot
for d in sargs for d in sargs
addUnicodeSeries!(o, d, iargs[:legend]) addUnicodeSeries!(o, d, iargs[:legend], xlim, ylim)
end end
# save the object # save the object
@ -121,10 +121,23 @@ end
# add a single series # 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 # get the function, or special handling for step/bar/hist
lt = d[:linetype] 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 stepstyle = :post
if lt == :path if lt == :path
func = UnicodePlots.lineplot! func = UnicodePlots.lineplot!

View File

@ -209,6 +209,30 @@ extendSeriesData(v::AVec, z) = (push!(v, z); v)
extendSeriesData(v::AVec, z::AVec) = (append!(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)
# --------------------------------------------------------------- # ---------------------------------------------------------------