working on big renaming
This commit is contained in:
parent
8c7d3a6e92
commit
58041cc64e
@ -55,7 +55,7 @@ end
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
function plot(pkg::BokehPackage; kw...)
|
||||
function _create_plot(pkg::BokehPackage; kw...)
|
||||
d = Dict(kw)
|
||||
|
||||
# dumpdict(d, "plot", true)
|
||||
@ -79,7 +79,7 @@ function plot(pkg::BokehPackage; kw...)
|
||||
end
|
||||
|
||||
|
||||
function plot!(::BokehPackage, plt::Plot; kw...)
|
||||
function _add_series(::BokehPackage, plt::Plot; kw...)
|
||||
d = Dict(kw)
|
||||
|
||||
# dumpdict(d, "plot!", true)
|
||||
@ -105,10 +105,10 @@ end
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
# TODO: override this to update plot items (title, xlabel, etc) after creation
|
||||
function updatePlotItems(plt::Plot{BokehPackage}, d::Dict)
|
||||
function _update_plot(plt::Plot{BokehPackage}, d::Dict)
|
||||
end
|
||||
|
||||
function updatePositionAndSize(plt::PlottingObject{BokehPackage}, d::Dict)
|
||||
function _update_plot_pos_size(plt::PlottingObject{BokehPackage}, d::Dict)
|
||||
end
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
@ -129,7 +129,7 @@ end
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
function addAnnotations{X,Y,V}(plt::Plot{BokehPackage}, anns::AVec{@compat(Tuple{X,Y,V})})
|
||||
function _add_annotations{X,Y,V}(plt::Plot{BokehPackage}, anns::AVec{@compat(Tuple{X,Y,V})})
|
||||
for ann in anns
|
||||
# TODO: add the annotation to the plot
|
||||
end
|
||||
@ -137,17 +137,17 @@ end
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
function buildSubplotObject!(subplt::Subplot{BokehPackage})
|
||||
function _create_subplot(subplt::Subplot{BokehPackage})
|
||||
# TODO: build the underlying Subplot object. this is where you might layout the panes within a GUI window, for example
|
||||
|
||||
end
|
||||
|
||||
|
||||
function expandLimits!(lims, plt::Plot{BokehPackage}, isx::Bool)
|
||||
function _expand_limits(lims, plt::Plot{BokehPackage}, isx::Bool)
|
||||
# TODO: call expand limits for each plot data
|
||||
end
|
||||
|
||||
function handleLinkInner(plt::Plot{BokehPackage}, isx::Bool)
|
||||
function _remove_axis(plt::Plot{BokehPackage}, isx::Bool)
|
||||
# TODO: if plot is inner subplot, might need to remove ticks or axis labels
|
||||
end
|
||||
|
||||
|
||||
@ -398,13 +398,13 @@ function updateGadflyGuides(plt::Plot, d::Dict)
|
||||
|
||||
ticks = get(d, :xticks, :auto)
|
||||
if ticks == :none
|
||||
handleLinkInner(plt, true)
|
||||
_remove_axis(plt, true)
|
||||
else
|
||||
addGadflyTicksGuide(gplt, ticks, true)
|
||||
end
|
||||
ticks = get(d, :yticks, :auto)
|
||||
if ticks == :none
|
||||
handleLinkInner(plt, false)
|
||||
_remove_axis(plt, false)
|
||||
else
|
||||
addGadflyTicksGuide(gplt, ticks, false)
|
||||
end
|
||||
@ -476,7 +476,7 @@ function createGadflyAnnotationObject(x, y, txt::PlotText)
|
||||
))
|
||||
end
|
||||
|
||||
function addAnnotations{X,Y,V}(plt::Plot{GadflyPackage}, anns::AVec{@compat(Tuple{X,Y,V})})
|
||||
function _add_annotations{X,Y,V}(plt::Plot{GadflyPackage}, anns::AVec{@compat(Tuple{X,Y,V})})
|
||||
for ann in anns
|
||||
push!(plt.o.guides, createGadflyAnnotationObject(ann...))
|
||||
end
|
||||
@ -486,7 +486,7 @@ end
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# create a blank Gadfly.Plot object
|
||||
function plot(pkg::GadflyPackage; kw...)
|
||||
function _create_plot(pkg::GadflyPackage; kw...)
|
||||
d = Dict(kw)
|
||||
gplt = createGadflyPlotObject(d)
|
||||
Plot(gplt, pkg, 0, d, Dict[])
|
||||
@ -494,7 +494,7 @@ end
|
||||
|
||||
|
||||
# plot one data series
|
||||
function plot!(::GadflyPackage, plt::Plot; kw...)
|
||||
function _add_series(::GadflyPackage, plt::Plot; kw...)
|
||||
d = Dict(kw)
|
||||
addGadflySeries!(plt, d)
|
||||
push!(plt.seriesargs, d)
|
||||
@ -503,7 +503,7 @@ end
|
||||
|
||||
|
||||
|
||||
function updatePlotItems(plt::Plot{GadflyPackage}, d::Dict)
|
||||
function _update_plot(plt::Plot{GadflyPackage}, d::Dict)
|
||||
updateGadflyGuides(plt, d)
|
||||
updateGadflyPlotTheme(plt, d)
|
||||
end
|
||||
@ -535,22 +535,22 @@ end
|
||||
|
||||
|
||||
# create the underlying object (each backend will do this differently)
|
||||
function buildSubplotObject!(subplt::Subplot{GadflyPackage}, isbefore::Bool)
|
||||
function _create_subplot(subplt::Subplot{GadflyPackage}, isbefore::Bool)
|
||||
isbefore && return false # wait until after plotting to create the subplots
|
||||
subplt.o = nothing
|
||||
true
|
||||
end
|
||||
|
||||
|
||||
function handleLinkInner(plt::Plot{GadflyPackage}, isx::Bool)
|
||||
function _remove_axis(plt::Plot{GadflyPackage}, isx::Bool)
|
||||
gplt = getGadflyContext(plt)
|
||||
addOrReplace(gplt.guides, isx ? Gadfly.Guide.xticks : Gadfly.Guide.yticks; label=false)
|
||||
addOrReplace(gplt.guides, isx ? Gadfly.Guide.xlabel : Gadfly.Guide.ylabel, "")
|
||||
end
|
||||
|
||||
function expandLimits!(lims, plt::Plot{GadflyPackage}, isx::Bool)
|
||||
function _expand_limits(lims, plt::Plot{GadflyPackage}, isx::Bool)
|
||||
for l in getGadflyContext(plt).layers
|
||||
expandLimits!(lims, l.mapping[isx ? :x : :y])
|
||||
_expand_limits(lims, l.mapping[isx ? :x : :y])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -1,19 +1,6 @@
|
||||
|
||||
# https://github.com/JuliaGraphics/Immerse.jl
|
||||
|
||||
# immutable ImmersePackage <: PlottingPackage end
|
||||
|
||||
# export immerse
|
||||
# immerse() = backend(:immerse)
|
||||
|
||||
|
||||
# supportedArgs(::ImmersePackage) = supportedArgs(GadflyPackage())
|
||||
# supportedAxes(::ImmersePackage) = supportedAxes(GadflyPackage())
|
||||
# supportedTypes(::ImmersePackage) = supportedTypes(GadflyPackage())
|
||||
# supportedStyles(::ImmersePackage) = supportedStyles(GadflyPackage())
|
||||
# supportedMarkers(::ImmersePackage) = supportedMarkers(GadflyPackage())
|
||||
# supportedScales(::ImmersePackage) = supportedScales(GadflyPackage())
|
||||
|
||||
|
||||
function createImmerseFigure(d::Dict)
|
||||
w,h = d[:size]
|
||||
@ -23,7 +10,7 @@ end
|
||||
|
||||
|
||||
# create a blank Gadfly.Plot object
|
||||
function plot(pkg::ImmersePackage; kw...)
|
||||
function _create_plot(pkg::ImmersePackage; kw...)
|
||||
d = Dict(kw)
|
||||
|
||||
# create the underlying Gadfly.Plot object
|
||||
@ -35,7 +22,7 @@ end
|
||||
|
||||
|
||||
# plot one data series
|
||||
function plot!(::ImmersePackage, plt::Plot; kw...)
|
||||
function _add_series(::ImmersePackage, plt::Plot; kw...)
|
||||
d = Dict(kw)
|
||||
addGadflySeries!(plt, d)
|
||||
push!(plt.seriesargs, d)
|
||||
@ -43,7 +30,7 @@ function plot!(::ImmersePackage, plt::Plot; kw...)
|
||||
end
|
||||
|
||||
|
||||
function updatePlotItems(plt::Plot{ImmersePackage}, d::Dict)
|
||||
function _update_plot(plt::Plot{ImmersePackage}, d::Dict)
|
||||
updateGadflyGuides(plt, d)
|
||||
updateGadflyPlotTheme(plt, d)
|
||||
end
|
||||
@ -52,7 +39,7 @@ end
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
function addAnnotations{X,Y,V}(plt::Plot{ImmersePackage}, anns::AVec{@compat(Tuple{X,Y,V})})
|
||||
function _add_annotations{X,Y,V}(plt::Plot{ImmersePackage}, anns::AVec{@compat(Tuple{X,Y,V})})
|
||||
for ann in anns
|
||||
push!(getGadflyContext(plt).guides, createGadflyAnnotationObject(ann...))
|
||||
end
|
||||
@ -78,7 +65,7 @@ end
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
|
||||
function buildSubplotObject!(subplt::Subplot{ImmersePackage}, isbefore::Bool)
|
||||
function _create_subplot(subplt::Subplot{ImmersePackage}, isbefore::Bool)
|
||||
return false
|
||||
# isbefore && return false
|
||||
end
|
||||
@ -125,15 +112,15 @@ function showSubplotObject(subplt::Subplot{ImmersePackage})
|
||||
end
|
||||
|
||||
|
||||
function handleLinkInner(plt::Plot{ImmersePackage}, isx::Bool)
|
||||
function _remove_axis(plt::Plot{ImmersePackage}, isx::Bool)
|
||||
gplt = getGadflyContext(plt)
|
||||
addOrReplace(gplt.guides, isx ? Gadfly.Guide.xticks : Gadfly.Guide.yticks; label=false)
|
||||
addOrReplace(gplt.guides, isx ? Gadfly.Guide.xlabel : Gadfly.Guide.ylabel, "")
|
||||
end
|
||||
|
||||
function expandLimits!(lims, plt::Plot{ImmersePackage}, isx::Bool)
|
||||
function _expand_limits(lims, plt::Plot{ImmersePackage}, isx::Bool)
|
||||
for l in getGadflyContext(plt).layers
|
||||
expandLimits!(lims, l.mapping[isx ? :x : :y])
|
||||
_expand_limits(lims, l.mapping[isx ? :x : :y])
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -398,7 +398,7 @@ end
|
||||
|
||||
usingRightAxis(plt::Plot{PyPlotPackage}) = any(args -> args[:axis] in (:right,:auto), plt.seriesargs)
|
||||
|
||||
function updatePlotItems(plt::Plot{PyPlotPackage}, d::Dict)
|
||||
function _update_plot(plt::Plot{PyPlotPackage}, d::Dict)
|
||||
figorax = plt.o
|
||||
ax = getLeftAxis(figorax)
|
||||
# PyPlot.sca(ax)
|
||||
@ -496,7 +496,7 @@ function createPyPlotAnnotationObject(plt::Plot{PyPlotPackage}, x, y, val::PlotT
|
||||
)
|
||||
end
|
||||
|
||||
function addAnnotations{X,Y,V}(plt::Plot{PyPlotPackage}, anns::AVec{@compat(Tuple{X,Y,V})})
|
||||
function _add_annotations{X,Y,V}(plt::Plot{PyPlotPackage}, anns::AVec{@compat(Tuple{X,Y,V})})
|
||||
for ann in anns
|
||||
createPyPlotAnnotationObject(plt, ann...)
|
||||
end
|
||||
@ -505,7 +505,7 @@ end
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
# NOTE: pyplot needs to build before
|
||||
function buildSubplotObject!(subplt::Subplot{PyPlotPackage}, isbefore::Bool)
|
||||
function _create_subplot(subplt::Subplot{PyPlotPackage}, isbefore::Bool)
|
||||
l = subplt.layout
|
||||
|
||||
w,h = map(px2inch, getinitargs(subplt,1)[:size])
|
||||
@ -540,8 +540,8 @@ function subplot(plts::AVec{Plot{PyPlotPackage}}, layout::SubplotLayout, d::Dict
|
||||
|
||||
subplt = Subplot(nothing, newplts, PyPlotPackage(), p, n, layout, d, true, false, false, (r,c) -> (nothing,nothing))
|
||||
|
||||
preprocessSubplot(subplt, d)
|
||||
buildSubplotObject!(subplt, true)
|
||||
_preprocess_subplot(subplt, d)
|
||||
_create_subplot(subplt, true)
|
||||
|
||||
for (i,plt) in enumerate(plts)
|
||||
for seriesargs in plt.seriesargs
|
||||
@ -549,13 +549,13 @@ function subplot(plts::AVec{Plot{PyPlotPackage}}, layout::SubplotLayout, d::Dict
|
||||
end
|
||||
end
|
||||
|
||||
postprocessSubplot(subplt, d)
|
||||
_postprocess_subplot(subplt, d)
|
||||
|
||||
subplt
|
||||
end
|
||||
|
||||
|
||||
function handleLinkInner(plt::Plot{PyPlotPackage}, isx::Bool)
|
||||
function _remove_axis(plt::Plot{PyPlotPackage}, isx::Bool)
|
||||
if isx
|
||||
plot!(plt, xticks=zeros(0), xlabel="")
|
||||
else
|
||||
@ -563,9 +563,9 @@ function handleLinkInner(plt::Plot{PyPlotPackage}, isx::Bool)
|
||||
end
|
||||
end
|
||||
|
||||
function expandLimits!(lims, plt::Plot{PyPlotPackage}, isx::Bool)
|
||||
function _expand_limits(lims, plt::Plot{PyPlotPackage}, isx::Bool)
|
||||
pltlims = plt.o.ax[isx ? :get_xbound : :get_ybound]()
|
||||
expandLimits!(lims, pltlims)
|
||||
_expand_limits(lims, pltlims)
|
||||
end
|
||||
|
||||
# -----------------------------------------------------------------
|
||||
|
||||
@ -131,7 +131,7 @@ function updateLimsAndTicks(plt::Plot{QwtPackage}, d::Dict, isx::Bool)
|
||||
end
|
||||
|
||||
|
||||
function updatePlotItems(plt::Plot{QwtPackage}, d::Dict)
|
||||
function _update_plot(plt::Plot{QwtPackage}, d::Dict)
|
||||
haskey(d, :title) && Qwt.title(plt.o, d[:title])
|
||||
haskey(d, :xlabel) && Qwt.xlabel(plt.o, d[:xlabel])
|
||||
haskey(d, :ylabel) && Qwt.ylabel(plt.o, d[:ylabel])
|
||||
@ -139,7 +139,7 @@ function updatePlotItems(plt::Plot{QwtPackage}, d::Dict)
|
||||
updateLimsAndTicks(plt, d, false)
|
||||
end
|
||||
|
||||
function updatePositionAndSize(plt::PlottingObject{QwtPackage}, d::Dict)
|
||||
function _update_plot_pos_size(plt::PlottingObject{QwtPackage}, d::Dict)
|
||||
haskey(d, :size) && Qwt.resizewidget(plt.o, d[:size]...)
|
||||
haskey(d, :pos) && Qwt.movewidget(plt.o, d[:pos]...)
|
||||
end
|
||||
@ -182,7 +182,7 @@ function createQwtAnnotation(plt::Plot, x, y, val::@compat(AbstractString))
|
||||
marker[:attach](plt.o.widget)
|
||||
end
|
||||
|
||||
function addAnnotations{X,Y,V}(plt::Plot{QwtPackage}, anns::AVec{@compat(Tuple{X,Y,V})})
|
||||
function _add_annotations{X,Y,V}(plt::Plot{QwtPackage}, anns::AVec{@compat(Tuple{X,Y,V})})
|
||||
for ann in anns
|
||||
createQwtAnnotation(plt, ann...)
|
||||
end
|
||||
@ -211,7 +211,7 @@ end
|
||||
# -------------------------------
|
||||
|
||||
# create the underlying object (each backend will do this differently)
|
||||
function buildSubplotObject!(subplt::Subplot{QwtPackage}, isbefore::Bool)
|
||||
function _create_subplot(subplt::Subplot{QwtPackage}, isbefore::Bool)
|
||||
isbefore && return false
|
||||
i = 0
|
||||
rows = Any[]
|
||||
@ -233,14 +233,14 @@ function buildSubplotObject!(subplt::Subplot{QwtPackage}, isbefore::Bool)
|
||||
true
|
||||
end
|
||||
|
||||
function expandLimits!(lims, plt::Plot{QwtPackage}, isx::Bool)
|
||||
function _expand_limits(lims, plt::Plot{QwtPackage}, isx::Bool)
|
||||
for series in plt.o.lines
|
||||
expandLimits!(lims, isx ? series.x : series.y)
|
||||
_expand_limits(lims, isx ? series.x : series.y)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
function handleLinkInner(plt::Plot{QwtPackage}, isx::Bool)
|
||||
function _remove_axis(plt::Plot{QwtPackage}, isx::Bool)
|
||||
end
|
||||
|
||||
|
||||
|
||||
@ -5,64 +5,7 @@
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
# supportedArgs(::[PkgName]Package) = _allArgs
|
||||
supportedArgs(::[PkgName]Package) = [
|
||||
:annotation,
|
||||
# :args,
|
||||
:axis,
|
||||
:background_color,
|
||||
:color,
|
||||
:fillrange,
|
||||
:fillcolor,
|
||||
:foreground_color,
|
||||
:group,
|
||||
# :heatmap_c,
|
||||
# :kwargs,
|
||||
:label,
|
||||
:layout,
|
||||
:legend,
|
||||
:linestyle,
|
||||
:linetype,
|
||||
:linewidth,
|
||||
:markershape,
|
||||
:markercolor,
|
||||
:markersize,
|
||||
:n,
|
||||
:nbins,
|
||||
:nc,
|
||||
:nr,
|
||||
# :pos,
|
||||
:smooth,
|
||||
# :ribbon,
|
||||
:show,
|
||||
:size,
|
||||
:title,
|
||||
:windowtitle,
|
||||
:x,
|
||||
:xlabel,
|
||||
:xlims,
|
||||
:xticks,
|
||||
:y,
|
||||
:ylabel,
|
||||
:ylims,
|
||||
# :yrightlabel,
|
||||
:yticks,
|
||||
# :xscale,
|
||||
# :yscale,
|
||||
# :xflip,
|
||||
# :yflip,
|
||||
# :z,
|
||||
]
|
||||
supportedAxes(::[PkgName]Package) = _allAxes
|
||||
supportedTypes(::[PkgName]Package) = _allTypes
|
||||
supportedStyles(::[PkgName]Package) = _allStyles
|
||||
supportedMarkers(::[PkgName]Package) = _allMarkers
|
||||
supportedScales(::[PkgName]Package) = _allScales
|
||||
subplotSupported(::[PkgName]Package) = false
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
||||
function plot(pkg::[PkgName]Package; kw...)
|
||||
function _create_plot(pkg::[PkgName]Package; kw...)
|
||||
d = Dict(kw)
|
||||
# TODO: create the window/canvas/context that is the plot within the backend (call it `o`)
|
||||
# TODO: initialize the plot... title, xlabel, bgcolor, etc
|
||||
@ -70,20 +13,29 @@ function plot(pkg::[PkgName]Package; kw...)
|
||||
end
|
||||
|
||||
|
||||
function plot!(::[PkgName]Package, plt::Plot; kw...)
|
||||
function _add_series(::[PkgName]Package, plt::Plot; kw...)
|
||||
d = Dict(kw)
|
||||
# TODO: add one series to the underlying package
|
||||
push!(plt.seriesargs, d)
|
||||
plt
|
||||
end
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
# TODO: override this to update plot items (title, xlabel, etc) after creation
|
||||
function updatePlotItems(plt::Plot{[PkgName]Package}, d::Dict)
|
||||
function _add_annotations{X,Y,V}(plt::Plot{[PkgName]Package}, anns::AVec{@compat(Tuple{X,Y,V})})
|
||||
for ann in anns
|
||||
# TODO: add the annotation to the plot
|
||||
end
|
||||
end
|
||||
|
||||
function updatePositionAndSize(plt::PlottingObject{[PkgName]Package}, d::Dict)
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
function _before_update_plot(plt::Plot{[PkgName]Package})
|
||||
end
|
||||
|
||||
# TODO: override this to update plot items (title, xlabel, etc) after creation
|
||||
function _update_plot(plt::Plot{[PkgName]Package}, d::Dict)
|
||||
end
|
||||
|
||||
function _update_plot_pos_size(plt::PlottingObject{[PkgName]Package}, d::Dict)
|
||||
end
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
@ -103,23 +55,15 @@ end
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
function addAnnotations{X,Y,V}(plt::Plot{[PkgName]Package}, anns::AVec{@compat(Tuple{X,Y,V})})
|
||||
for ann in anns
|
||||
# TODO: add the annotation to the plot
|
||||
end
|
||||
end
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
function buildSubplotObject!(subplt::Subplot{[PkgName]Package})
|
||||
function _create_subplot(subplt::Subplot{[PkgName]Package})
|
||||
# TODO: build the underlying Subplot object. this is where you might layout the panes within a GUI window, for example
|
||||
end
|
||||
|
||||
function expandLimits!(lims, plt::Plot{[PkgName]Package}, isx::Bool)
|
||||
function _expand_limits(lims, plt::Plot{[PkgName]Package}, isx::Bool)
|
||||
# TODO: call expand limits for each plot data
|
||||
end
|
||||
|
||||
function handleLinkInner(plt::Plot{[PkgName]Package}, isx::Bool)
|
||||
function _remove_axis(plt::Plot{[PkgName]Package}, isx::Bool)
|
||||
# TODO: if plot is inner subplot, might need to remove ticks or axis labels
|
||||
end
|
||||
|
||||
|
||||
@ -15,7 +15,7 @@ function rebuildUnicodePlot!(plt::Plot)
|
||||
if get(iargs, :xlims, :auto) == :auto
|
||||
xlim = [Inf, -Inf]
|
||||
for d in sargs
|
||||
expandLimits!(xlim, d[:x])
|
||||
_expand_limits(xlim, d[:x])
|
||||
end
|
||||
else
|
||||
xmin, xmax = iargs[:xlims]
|
||||
@ -25,7 +25,7 @@ function rebuildUnicodePlot!(plt::Plot)
|
||||
if get(iargs, :ylims, :auto) == :auto
|
||||
ylim = [Inf, -Inf]
|
||||
for d in sargs
|
||||
expandLimits!(ylim, d[:y])
|
||||
_expand_limits(ylim, d[:y])
|
||||
end
|
||||
else
|
||||
ymin, ymax = iargs[:ylims]
|
||||
@ -135,7 +135,7 @@ function plot!(::UnicodePlotsPackage, plt::Plot; kw...)
|
||||
end
|
||||
|
||||
|
||||
function updatePlotItems(plt::Plot{UnicodePlotsPackage}, d::Dict)
|
||||
function _update_plot(plt::Plot{UnicodePlotsPackage}, d::Dict)
|
||||
for k in (:title, :xlabel, :ylabel, :xlims, :ylims)
|
||||
if haskey(d, k)
|
||||
plt.initargs[k] = d[k]
|
||||
@ -175,7 +175,7 @@ end
|
||||
|
||||
# we don't do very much for subplots... just stack them vertically
|
||||
|
||||
function buildSubplotObject!(subplt::Subplot{UnicodePlotsPackage}, isbefore::Bool)
|
||||
function _create_subplot(subplt::Subplot{UnicodePlotsPackage}, isbefore::Bool)
|
||||
isbefore && return false
|
||||
true
|
||||
end
|
||||
|
||||
@ -157,7 +157,7 @@ end
|
||||
:yscale => :ylog,
|
||||
)
|
||||
|
||||
function updatePlotItems(plt::Plot{WinstonPackage}, d::Dict)
|
||||
function _update_plot(plt::Plot{WinstonPackage}, d::Dict)
|
||||
window, canvas, wplt = getWinstonItems(plt)
|
||||
for k in (:xlabel, :ylabel, :title, :xlims, :ylims)
|
||||
if haskey(d, k)
|
||||
@ -182,7 +182,7 @@ function createWinstonAnnotationObject(plt::Plot{WinstonPackage}, x, y, val::@co
|
||||
Winston.text(x, y, val)
|
||||
end
|
||||
|
||||
function addAnnotations{X,Y,V}(plt::Plot{WinstonPackage}, anns::AVec{@compat(Tuple{X,Y,V})})
|
||||
function _add_annotations{X,Y,V}(plt::Plot{WinstonPackage}, anns::AVec{@compat(Tuple{X,Y,V})})
|
||||
for ann in anns
|
||||
createWinstonAnnotationObject(plt, ann...)
|
||||
end
|
||||
@ -191,7 +191,7 @@ end
|
||||
|
||||
# ----------------------------------------------------------------
|
||||
|
||||
function buildSubplotObject!(subplt::Subplot{WinstonPackage}, isbefore::Bool)
|
||||
function _create_subplot(subplt::Subplot{WinstonPackage}, isbefore::Bool)
|
||||
# TODO: build the underlying Subplot object. this is where you might layout the panes within a GUI window, for example
|
||||
end
|
||||
|
||||
|
||||
@ -151,7 +151,19 @@ function stroke(args...; α::Real = -1.0)
|
||||
for arg in args
|
||||
T = typeof(arg)
|
||||
|
||||
# if arg in
|
||||
if arg in _allStyles
|
||||
style = arg
|
||||
elseif T <: Colorant
|
||||
color = arg
|
||||
elseif T <: @compat Union{Symbol,AbstractString}
|
||||
try
|
||||
color = parse(Colorant, string(arg))
|
||||
end
|
||||
elseif typeof(arg) <: Real
|
||||
width = arg
|
||||
else
|
||||
warn("Unused stroke arg: $arg ($(typeof(arg)))")
|
||||
end
|
||||
end
|
||||
|
||||
Stroke(width, color, style)
|
||||
|
||||
14
src/plot.jl
14
src/plot.jl
@ -90,7 +90,7 @@ function plot!(plt::Plot, args...; kw...)
|
||||
preparePlotUpdate(plt)
|
||||
|
||||
# get the list of dictionaries, one per series
|
||||
kwList, xmeta, ymeta = createKWargsList(plt, groupargs..., args...; d...)
|
||||
seriesArgList, xmeta, ymeta = createKWargsList(plt, groupargs..., args...; d...)
|
||||
|
||||
# if we were able to extract guide information from the series inputs, then update the plot
|
||||
# @show xmeta, ymeta
|
||||
@ -98,7 +98,7 @@ function plot!(plt::Plot, args...; kw...)
|
||||
updateDictWithMeta(d, plt.initargs, ymeta, false)
|
||||
|
||||
# now we can plot the series
|
||||
for (i,di) in enumerate(kwList)
|
||||
for (i,di) in enumerate(seriesArgList)
|
||||
plt.n += 1
|
||||
|
||||
setTicksFromStringVector(d, di, :x, :xticks)
|
||||
@ -114,7 +114,7 @@ function plot!(plt::Plot, args...; kw...)
|
||||
plot!(plt.backend, plt; di...)
|
||||
end
|
||||
|
||||
addAnnotations(plt, d)
|
||||
_add_annotations(plt, d)
|
||||
|
||||
warnOnUnsupportedScales(plt.backend, d)
|
||||
|
||||
@ -123,10 +123,10 @@ function plot!(plt::Plot, args...; kw...)
|
||||
if !haskey(d, :subplot)
|
||||
merge!(plt.initargs, d)
|
||||
dumpdict(plt.initargs, "Updating plot items")
|
||||
updatePlotItems(plt, plt.initargs)
|
||||
_update_plot(plt, plt.initargs)
|
||||
end
|
||||
|
||||
updatePositionAndSize(plt, d)
|
||||
_update_plot_pos_size(plt, d)
|
||||
|
||||
current(plt)
|
||||
|
||||
@ -184,10 +184,10 @@ annotations{X,Y,V}(t::@compat(Tuple{X,Y,V})) = [t]
|
||||
annotations(anns) = error("Expecting a tuple (or vector of tuples) for annotations: ",
|
||||
"(x, y, annotation)\n got: $(typeof(anns))")
|
||||
|
||||
function addAnnotations(plt::Plot, d::Dict)
|
||||
function _add_annotations(plt::Plot, d::Dict)
|
||||
anns = annotations(get(d, :annotation, nothing))
|
||||
if !isempty(anns)
|
||||
addAnnotations(plt, anns)
|
||||
_add_annotations(plt, anns)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@ -50,10 +50,10 @@ include("backends/bokeh.jl")
|
||||
|
||||
plot(pkg::PlottingPackage; kw...) = error("plot($pkg; kw...) is not implemented")
|
||||
plot!(pkg::PlottingPackage, plt::Plot; kw...) = error("plot!($pkg, plt; kw...) is not implemented")
|
||||
updatePlotItems(pkg::PlottingPackage, plt::Plot, d::Dict) = error("updatePlotItems($pkg, plt, d) is not implemented")
|
||||
_update_plot(pkg::PlottingPackage, plt::Plot, d::Dict) = error("_update_plot($pkg, plt, d) is not implemented")
|
||||
# Base.display(pkg::PlottingPackage, plt::Plot) = error("display($pkg, plt) is not implemented")
|
||||
|
||||
updatePositionAndSize{P<:PlottingPackage}(plt::PlottingObject{P}, d::Dict) = nothing #error("updatePositionAndSize(plt,d) is not implemented for $P")
|
||||
_update_plot_pos_size{P<:PlottingPackage}(plt::PlottingObject{P}, d::Dict) = nothing #error("_update_plot_pos_size(plt,d) is not implemented for $P")
|
||||
|
||||
subplot(pkg::PlottingPackage; kw...) = error("subplot($pkg; kw...) is not implemented")
|
||||
subplot!(pkg::PlottingPackage, subplt::Subplot; kw...) = error("subplot!($pkg, subplt; kw...) is not implemented")
|
||||
|
||||
@ -81,7 +81,7 @@ Base.getindex(layout::GridLayout, r::Int, c::Int) = (r-1) * layout.nc + c
|
||||
Base.getindex(subplt::Subplot, args...) = subplt.plts[subplt.layout[args...]]
|
||||
|
||||
# handle "linking" the subplot axes together
|
||||
# each backend should implement the handleLinkInner and expandLimits! methods
|
||||
# each backend should implement the _remove_axis and _expand_limits methods
|
||||
function linkAxis(subplt::Subplot, isx::Bool)
|
||||
|
||||
# collect the list of plots and the expanded limits for those plots that should be linked on this axis
|
||||
@ -104,7 +104,7 @@ function linkAxis(subplt::Subplot, isx::Bool)
|
||||
isinner = (isx && r < nrows(subplt.layout)) || (!isx && !firstone)
|
||||
push!(includedPlots, (plt, isinner, k))
|
||||
|
||||
expandLimits!(lims[k], plt, isx)
|
||||
_expand_limits(lims[k], plt, isx)
|
||||
end
|
||||
|
||||
end
|
||||
@ -112,7 +112,7 @@ function linkAxis(subplt::Subplot, isx::Bool)
|
||||
# do the axis adjustments
|
||||
for (plt, isinner, k) in includedPlots
|
||||
if isinner
|
||||
handleLinkInner(plt, isx)
|
||||
_remove_axis(plt, isx)
|
||||
end
|
||||
(isx ? xlims! : ylims!)(plt, lims[k]...)
|
||||
end
|
||||
@ -209,29 +209,8 @@ function subplot{P<:PlottingPackage}(plts::AVec{Plot{P}}, layout::SubplotLayout,
|
||||
n = sum([plt.n for plt in plts])
|
||||
subplt = Subplot(nothing, collect(plts), P(), p, n, layout, Dict(), false, false, false, (r,c) -> (nothing,nothing))
|
||||
|
||||
# preprocessArgs!(d)
|
||||
|
||||
# #
|
||||
# for (i,plt) in enumerate(plts)
|
||||
# di = copy(plt.initargs)
|
||||
|
||||
# for ck in (:background_color, :foreground_color, :color_palette)
|
||||
# # if we have a value to override, do it
|
||||
# if haskey(d, ck)
|
||||
# di[ck] = get_mod(d[ck], i)
|
||||
# end
|
||||
|
||||
|
||||
|
||||
# # build a new dict from the initargs of the plots
|
||||
# iargs = Dict()
|
||||
# for k in keys(_plotDefaults)
|
||||
# iargs[k] = Any[plt.initargs[k] for plt in plts]'
|
||||
# end
|
||||
# merge!(iargs, d)
|
||||
|
||||
preprocessSubplot(subplt, d)
|
||||
postprocessSubplot(subplt, d)
|
||||
_preprocess_subplot(subplt, d)
|
||||
_postprocess_subplot(subplt, d)
|
||||
|
||||
subplt
|
||||
end
|
||||
@ -241,7 +220,7 @@ end
|
||||
# ------------------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
function preprocessSubplot(subplt::Subplot, d::Dict)
|
||||
function _preprocess_subplot(subplt::Subplot, d::Dict)
|
||||
validateSubplotSupported()
|
||||
preprocessArgs!(d)
|
||||
dumpdict(d, "After subplot! preprocessing")
|
||||
@ -256,8 +235,6 @@ function preprocessSubplot(subplt::Subplot, d::Dict)
|
||||
# those into the plot's initargs. (example... `palette = [:blues :reds]` goes into subplt.initargs,
|
||||
# then the ColorGradient for :blues/:reds is merged into plot 1/2 initargs, which is then used for color selection)
|
||||
for i in 1:length(subplt.layout)
|
||||
# di = getPlotArgs(backend(), subplt.initargs, i)
|
||||
# merge!(subplt.plts[i].initargs, di)
|
||||
subplt.plts[i].initargs = getPlotArgs(backend(), merge(subplt.plts[i].initargs, d), i)
|
||||
end
|
||||
merge!(subplt.initargs, d)
|
||||
@ -271,37 +248,20 @@ function preprocessSubplot(subplt::Subplot, d::Dict)
|
||||
end
|
||||
end
|
||||
|
||||
function postprocessSubplot(subplt::Subplot, d::Dict)
|
||||
function _postprocess_subplot(subplt::Subplot, d::Dict)
|
||||
# init (after plot creation)
|
||||
if !subplt.initialized
|
||||
subplt.initialized = buildSubplotObject!(subplt, false)
|
||||
subplt.initialized = _create_subplot(subplt, false)
|
||||
end
|
||||
|
||||
# add title, axis labels, ticks, etc
|
||||
for (i,plt) in enumerate(subplt.plts)
|
||||
|
||||
# # # get the full initargs, overriding any new settings
|
||||
# # di = copy(merge(plt.initargs, d))
|
||||
# di = copy(d)
|
||||
|
||||
# for (k,v) in di
|
||||
# if typeof(v) <: AVec
|
||||
# di[k] = v[mod1(i, length(v))]
|
||||
# elseif typeof(v) <: AMat
|
||||
# m = size(v,2)
|
||||
# di[k] = (size(v,1) == 1 ? v[1, mod1(i, m)] : v[:, mod1(i, m)])
|
||||
# end
|
||||
# end
|
||||
|
||||
# di = merge!(plt.initargs, di)
|
||||
|
||||
di = plt.initargs
|
||||
|
||||
dumpdict(di, "Updating sp $i")
|
||||
updatePlotItems(plt, di)
|
||||
_update_plot(plt, di)
|
||||
end
|
||||
|
||||
updatePositionAndSize(subplt, d)
|
||||
_update_plot_pos_size(subplt, d)
|
||||
|
||||
# handle links
|
||||
subplt.linkx && linkAxis(subplt, true)
|
||||
@ -335,14 +295,14 @@ function subplot!(subplt::Subplot, args...; kw...)
|
||||
# validateSubplotSupported()
|
||||
|
||||
d = Dict(kw)
|
||||
preprocessSubplot(subplt, d)
|
||||
_preprocess_subplot(subplt, d)
|
||||
|
||||
# create the underlying object (each backend will do this differently)
|
||||
# note: we call it once before doing the individual plots, and once after
|
||||
# this is because some backends need to set up the subplots and then plot,
|
||||
# and others need to do it the other way around
|
||||
if !subplt.initialized
|
||||
subplt.initialized = buildSubplotObject!(subplt, true)
|
||||
subplt.initialized = _create_subplot(subplt, true)
|
||||
end
|
||||
|
||||
# handle grouping
|
||||
@ -365,17 +325,6 @@ function subplot!(subplt::Subplot, args...; kw...)
|
||||
plt = getplot(subplt)
|
||||
plt.n += 1
|
||||
|
||||
# # update the plot's initargs for things such as palettes, etc
|
||||
# for (k,v) in subplt.initargs
|
||||
# haskey(_plotDefaults, k) || continue
|
||||
# if typeof(v) <: AVec
|
||||
# plt.initargs[k] = v[mod1(i, length(v))]
|
||||
# elseif typeof(v) <: AMat
|
||||
# m = size(v,2)
|
||||
# plt.initargs[k] = (size(v,1) == 1 ? v[1, mod1(i, m)] : v[:, mod1(i, m)])
|
||||
# end
|
||||
# end
|
||||
|
||||
# cleanup the dictionary that we pass into the plot! command
|
||||
di[:show] = false
|
||||
di[:subplot] = true
|
||||
@ -389,7 +338,7 @@ function subplot!(subplt::Subplot, args...; kw...)
|
||||
_plot_from_subplot!(plt; di...)
|
||||
end
|
||||
|
||||
postprocessSubplot(subplt, d)
|
||||
_postprocess_subplot(subplt, d)
|
||||
|
||||
# show it automatically?
|
||||
if haskey(d, :show) && d[:show]
|
||||
@ -407,10 +356,9 @@ function _plot_from_subplot!(plt::Plot, args...; kw...)
|
||||
setTicksFromStringVector(d, d, :x, :xticks)
|
||||
setTicksFromStringVector(d, d, :y, :yticks)
|
||||
|
||||
# dumpdict(d, "Plot from subplot")
|
||||
plot!(plt.backend, plt; d...)
|
||||
_add_series(plt.backend, plt; d...)
|
||||
|
||||
addAnnotations(plt, d)
|
||||
_add_annotations(plt, d)
|
||||
warnOnUnsupportedScales(plt.backend, d)
|
||||
end
|
||||
|
||||
|
||||
@ -131,7 +131,7 @@ maketuple{T,S}(x::@compat(Tuple{T,S})) = x
|
||||
unzip{T,S}(v::AVec{@compat(Tuple{T,S})}) = [vi[1] for vi in v], [vi[2] for vi in v]
|
||||
|
||||
# given 2-element lims and a vector of data x, widen lims to account for the extrema of x
|
||||
function expandLimits!(lims, x)
|
||||
function _expand_limits(lims, x)
|
||||
try
|
||||
e1, e2 = extrema(x)
|
||||
lims[1] = min(lims[1], e1)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user