From a6ce2e691d0e7f14b469c134967a611f9a27b659 Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Sun, 15 May 2016 12:14:18 -0400 Subject: [PATCH] changed add_series to accept Series and push to list automatically; default add_series simplifies; removed old supported.jl --- src/backends.jl | 1 + src/backends/bokeh.jl | 9 +- src/backends/gadfly.jl | 9 +- src/backends/glvisualize.jl | 11 +- src/backends/gr.jl | 38 +- src/backends/immerse.jl | 14 +- src/backends/pgfplots.jl | 24 +- src/backends/plotly.jl | 10 +- src/backends/plotlyjs.jl | 7 +- src/backends/pyplot.jl | 8 +- src/backends/qwt.jl | 9 +- src/backends/supported.jl | 698 ----------------------------------- src/backends/template.jl | 4 +- src/backends/unicodeplots.jl | 8 +- src/plot.jl | 19 +- src/recipes.jl | 11 +- src/types.jl | 56 ++- 17 files changed, 140 insertions(+), 796 deletions(-) delete mode 100644 src/backends/supported.jl diff --git a/src/backends.jl b/src/backends.jl index cb5ccdad..956861f5 100644 --- a/src/backends.jl +++ b/src/backends.jl @@ -54,6 +54,7 @@ subplot!(pkg::AbstractBackend, subplt::Subplot; kw...) = error("subplot!($pkg, # don't do anything as a default _create_backend_figure(plt::Plot) = nothing _before_add_series(plt::Plot) = nothing +_add_series(plt::Plot) = nothing _add_annotations{X,Y,V}(plt::Plot, anns::AVec{Tuple{X,Y,V}}) = nothing _update_plot_pos_size(plt::AbstractPlot, d::KW) = nothing diff --git a/src/backends/bokeh.jl b/src/backends/bokeh.jl index 91044421..f842b355 100644 --- a/src/backends/bokeh.jl +++ b/src/backends/bokeh.jl @@ -154,8 +154,9 @@ function _create_backend_figure(plt::Plot{BokehBackend}) end -function _add_series(::BokehBackend, plt::Plot, d::KW) - bdata = Dict{Symbol, Vector}(:x => collect(d[:x]), :y => collect(d[:y])) +# function _add_series(::BokehBackend, plt::Plot, d::KW) +function _add_series(plt::Plot{BokehBackend}, series::Series) + bdata = Dict{Symbol, Vector}(:x => collect(series.d[:x]), :y => collect(series.d[:y])) glyph = Bokeh.Bokehjs.Glyph( glyphtype = bokeh_glyph_type(d), @@ -169,8 +170,8 @@ function _add_series(::BokehBackend, plt::Plot, d::KW) legend = nothing # TODO push!(plt.o.datacolumns, Bokeh.BokehDataSet(bdata, glyph, legend)) - push!(plt.seriesargs, d) - plt + # push!(plt.seriesargs, d) + # plt end # ---------------------------------------------------------------- diff --git a/src/backends/gadfly.jl b/src/backends/gadfly.jl index b4f806e4..67d817c4 100644 --- a/src/backends/gadfly.jl +++ b/src/backends/gadfly.jl @@ -580,16 +580,17 @@ end # plot one data series -function _add_series(::GadflyBackend, plt::Plot, d::KW) +# function _add_series(::GadflyBackend, plt::Plot, d::KW) +function _add_series(plt::Plot{GadflyBackend}, series::Series) # first clear out the temporary layer gplt = getGadflyContext(plt) if gplt.layers[1].geom.tag == :remove gplt.layers = gplt.layers[2:end] end - addGadflySeries!(plt, d) - push!(plt.seriesargs, d) - plt + addGadflySeries!(plt, series.d) + # push!(plt.seriesargs, d) + # plt end diff --git a/src/backends/glvisualize.jl b/src/backends/glvisualize.jl index 832262cd..150f1fbf 100644 --- a/src/backends/glvisualize.jl +++ b/src/backends/glvisualize.jl @@ -95,13 +95,14 @@ function _create_backend_figure(plt::Plot{GLVisualizeBackend}) end -function _add_series(::GLVisualizeBackend, plt::Plot, d::KW) +# function _add_series(::GLVisualizeBackend, plt::Plot, d::KW) +function _add_series(plt::Plot{GLVisualizeBackend}, series::Series) # TODO: add one series to the underlying package - push!(plt.seriesargs, d) + # push!(plt.seriesargs, d) # TODO: this should be moved to the display method? - x,y,z=map(Float32,d[:x]), map(Float32,d[:y]), map(Float32,d[:z].surf) - GLVisualize.view(GLVisualize.visualize((x*ones(y)', ones(x)*y', z), :surface),plt.o.window) - plt + x, y, z = map(Float32, series.d[:x]), map(Float32, series.d[:y]), map(Float32, series.d[:z].surf) + GLVisualize.view(GLVisualize.visualize((x*ones(y)', ones(x)*y', z), :surface), plt.o.window) + # plt end function _add_annotations{X,Y,V}(plt::Plot{GLVisualizeBackend}, anns::AVec{@compat(Tuple{X,Y,V})}) diff --git a/src/backends/gr.jl b/src/backends/gr.jl index 056cec38..767ba3f2 100644 --- a/src/backends/gr.jl +++ b/src/backends/gr.jl @@ -852,10 +852,10 @@ end # Plot(nothing, pkg, 0, d, KW[]) # end -function _add_series(::GRBackend, plt::Plot, d::KW) - push!(plt.seriesargs, d) - plt -end +# function _add_series(::GRBackend, plt::Plot, d::KW) +# push!(plt.seriesargs, d) +# plt +# end function _add_annotations{X,Y,V}(plt::Plot{GRBackend}, anns::AVec{@compat(Tuple{X,Y,V})}) if haskey(plt.plotargs, :anns) @@ -867,8 +867,8 @@ end # ---------------------------------------------------------------- -function _before_update_plot(plt::Plot{GRBackend}) -end +# function _before_update_plot(plt::Plot{GRBackend}) +# end function _update_plot(plt::Plot{GRBackend}, d::KW) for k in (:title, :xlabel, :ylabel) @@ -876,8 +876,8 @@ function _update_plot(plt::Plot{GRBackend}, d::KW) end end -function _update_plot_pos_size(plt::AbstractPlot{GRBackend}, d::KW) -end +# function _update_plot_pos_size(plt::AbstractPlot{GRBackend}, d::KW) +# end # ---------------------------------------------------------------- @@ -894,17 +894,17 @@ end # ---------------------------------------------------------------- -function _create_subplot(subplt::Subplot{GRBackend}, isbefore::Bool) - true -end - -function _expand_limits(lims, plt::Plot{GRBackend}, isx::Bool) - # TODO: call expand limits for each plot data -end - -function _remove_axis(plt::Plot{GRBackend}, isx::Bool) - # TODO: if plot is inner subplot, might need to remove ticks or axis labels -end +# function _create_subplot(subplt::Subplot{GRBackend}, isbefore::Bool) +# true +# end +# +# function _expand_limits(lims, plt::Plot{GRBackend}, isx::Bool) +# # TODO: call expand limits for each plot data +# end +# +# function _remove_axis(plt::Plot{GRBackend}, isx::Bool) +# # TODO: if plot is inner subplot, might need to remove ticks or axis labels +# end # ---------------------------------------------------------------- diff --git a/src/backends/immerse.jl b/src/backends/immerse.jl index 14d5ac0a..733c1b79 100644 --- a/src/backends/immerse.jl +++ b/src/backends/immerse.jl @@ -41,11 +41,15 @@ function _create_backend_figure(plt::Plot{ImmerseBackend}) end -# plot one data series -function _add_series(::ImmerseBackend, plt::Plot, d::KW) - addGadflySeries!(plt, d) - push!(plt.seriesargs, d) - plt +# # plot one data series +# function _add_series(::ImmerseBackend, plt::Plot, d::KW) +# addGadflySeries!(plt, d) +# push!(plt.seriesargs, d) +# plt +# end + +function _add_series(plt::Plot{ImmerseBackend}, series::Series) + addGadflySeries!(plt, series.d) end diff --git a/src/backends/pgfplots.jl b/src/backends/pgfplots.jl index ee6072da..eda0503b 100644 --- a/src/backends/pgfplots.jl +++ b/src/backends/pgfplots.jl @@ -236,11 +236,11 @@ end # end -function _add_series(::PGFPlotsBackend, plt::Plot, d::KW) - # TODO: add one series to the underlying package - push!(plt.seriesargs, d) - plt -end +# function _add_series(::PGFPlotsBackend, plt::Plot, d::KW) +# # TODO: add one series to the underlying package +# push!(plt.seriesargs, d) +# plt +# end function _add_annotations{X,Y,V}(plt::Plot{PGFPlotsBackend}, anns::AVec{@compat(Tuple{X,Y,V})}) # set or add to the annotation_list @@ -285,13 +285,13 @@ end # true # end -function _expand_limits(lims, plt::Plot{PGFPlotsBackend}, isx::Bool) - # TODO: call expand limits for each plot data -end - -function _remove_axis(plt::Plot{PGFPlotsBackend}, isx::Bool) - # TODO: if plot is inner subplot, might need to remove ticks or axis labels -end +# function _expand_limits(lims, plt::Plot{PGFPlotsBackend}, isx::Bool) +# # TODO: call expand limits for each plot data +# end +# +# function _remove_axis(plt::Plot{PGFPlotsBackend}, isx::Bool) +# # TODO: if plot is inner subplot, might need to remove ticks or axis labels +# end # ---------------------------------------------------------------- diff --git a/src/backends/plotly.jl b/src/backends/plotly.jl index 4eb0d0d8..bf2adcd5 100644 --- a/src/backends/plotly.jl +++ b/src/backends/plotly.jl @@ -91,11 +91,11 @@ end # end -function _add_series(::PlotlyBackend, plt::Plot, d::KW) - # TODO: add one series to the underlying package - push!(plt.seriesargs, d) - plt -end +# function _add_series(::PlotlyBackend, plt::Plot, d::KW) +# # TODO: add one series to the underlying package +# push!(plt.seriesargs, d) +# plt +# end function _add_annotations{X,Y,V}(plt::Plot{PlotlyBackend}, anns::AVec{@compat(Tuple{X,Y,V})}) # set or add to the annotation_list diff --git a/src/backends/plotlyjs.jl b/src/backends/plotlyjs.jl index f1d0c449..f57e05d9 100644 --- a/src/backends/plotlyjs.jl +++ b/src/backends/plotlyjs.jl @@ -113,7 +113,8 @@ function _create_backend_figure(plt::Plot{PlotlyJSBackend}) end -function _add_series(::PlotlyJSBackend, plt::Plot, d::KW) +function _add_series(plt::Plot{PlotlyJSBackend}, series::Series) + d = series.d syncplot = plt.o # add to the data array @@ -122,8 +123,8 @@ function _add_series(::PlotlyJSBackend, plt::Plot, d::KW) gt = PlotlyJS.GenericTrace(typ; pdict...) PlotlyJS.addtraces!(syncplot, gt) - push!(plt.seriesargs, d) - plt + # push!(plt.seriesargs, d) + # plt end diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 0eceaa06..13981157 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -364,7 +364,9 @@ pylinecolormap(d::KW) = getPyPlotColorMap(d[:linecolor], d[:linealpha]) pymarkercolormap(d::KW) = getPyPlotColorMap(d[:markercolor], d[:markeralpha]) pyfillcolormap(d::KW) = getPyPlotColorMap(d[:fillcolor], d[:fillalpha]) -function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) +# function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) +function _add_series(plt::Plot{PyPlotBackend}, series::Series) + d = series.d st = d[:seriestype] if !(st in supportedTypes(pkg)) error("seriestype $(st) is unsupported in PyPlot. Choose from: $(supportedTypes(pkg))") @@ -758,8 +760,8 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) push!(handles, handle) end - push!(plt.seriesargs, d) - plt + # push!(plt.seriesargs, d) + # plt end diff --git a/src/backends/qwt.jl b/src/backends/qwt.jl index 4cf82e2d..0e7a1904 100644 --- a/src/backends/qwt.jl +++ b/src/backends/qwt.jl @@ -137,13 +137,14 @@ function _create_backend_figure(plt::Plot{QwtBackend}) # plt end -function _add_series(::QwtBackend, plt::Plot, d::KW) - d = adjustQwtKeywords(plt, false; d...) +# function _add_series(::QwtBackend, plt::Plot, d::KW) +function _add_series(plt::Plot{QwtBackend}, series::Series) + d = adjustQwtKeywords(plt, false; series.d...) fixcolors(d) dumpdict(d,"\n\n!!! plot!") Qwt.oplot(plt.o; d...) - push!(plt.seriesargs, d) - plt + # push!(plt.seriesargs, d) + # plt end diff --git a/src/backends/supported.jl b/src/backends/supported.jl deleted file mode 100644 index ed518ca4..00000000 --- a/src/backends/supported.jl +++ /dev/null @@ -1,698 +0,0 @@ -# -# supportedAxes(::AbstractBackend) = [:left] -# supportedTypes(::AbstractBackend) = [] -# supportedStyles(::AbstractBackend) = [:solid] -# supportedMarkers(::AbstractBackend) = [:none] -# supportedScales(::AbstractBackend) = [:identity] -# subplotSupported(::AbstractBackend) = false -# stringsSupported(::AbstractBackend) = false -# -# supportedAxes() = supportedAxes(backend()) -# supportedTypes() = supportedTypes(backend()) -# supportedStyles() = supportedStyles(backend()) -# supportedMarkers() = supportedMarkers(backend()) -# supportedScales() = supportedScales(backend()) -# subplotSupported() = subplotSupported(backend()) -# stringsSupported() = stringsSupported(backend()) - - -# -------------------------------------------------------------------------------------- -# -# -# supportedArgs(::GadflyBackend) = [ -# :annotation, -# :background_color, :foreground_color, :color_palette, -# :group, -# :label, -# :seriestype, -# :seriescolor, :seriesalpha, -# :linecolor, :linestyle, :linewidth, :linealpha, -# :markershape, :markercolor, :markersize, :markeralpha, -# :markerstrokewidth, :markerstrokecolor, :markerstrokealpha, -# :fillrange, :fillcolor, :fillalpha, -# :bins, -# :n, :nc, :nr, :layout, -# :smooth, -# :title, :windowtitle, :show, :size, -# :x, :xlabel, :xlims, :xticks, :xscale, :xflip, -# :y, :ylabel, :ylims, :yticks, :yscale, :yflip, -# # :z, :zlabel, :zlims, :zticks, :zscale, :zflip, -# :z, -# :tickfont, :guidefont, :legendfont, -# :grid, :legend, :colorbar, -# :marker_z, :levels, -# :xerror, :yerror, -# :ribbon, :quiver, -# :orientation, -# ] -# supportedAxes(::GadflyBackend) = [:auto, :left] -# supportedTypes(::GadflyBackend) = [ -# :none, :line, :path, :steppre, :steppost, :sticks, -# :scatter, :hist2d, :hexbin, :hist, -# :bar, :box, :violin, :quiver, -# :hline, :vline, :contour, :shape -# ] -# supportedStyles(::GadflyBackend) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot] -# supportedMarkers(::GadflyBackend) = vcat(_allMarkers, Shape) -# supportedScales(::GadflyBackend) = [:identity, :ln, :log2, :log10, :asinh, :sqrt] -# subplotSupported(::GadflyBackend) = true -# -# -# # -------------------------------------------------------------------------------------- - -# -# supportedArgs(::ImmerseBackend) = supportedArgs(GadflyBackend()) -# supportedAxes(::ImmerseBackend) = supportedAxes(GadflyBackend()) -# supportedTypes(::ImmerseBackend) = supportedTypes(GadflyBackend()) -# supportedStyles(::ImmerseBackend) = supportedStyles(GadflyBackend()) -# supportedMarkers(::ImmerseBackend) = supportedMarkers(GadflyBackend()) -# supportedScales(::ImmerseBackend) = supportedScales(GadflyBackend()) -# subplotSupported(::ImmerseBackend) = true -# -# # -------------------------------------------------------------------------------------- - -# -# -# supportedArgs(::PyPlotBackend) = [ -# :annotation, -# :background_color, :foreground_color, :color_palette, -# :background_color_legend, :background_color_inside, :background_color_outside, -# :foreground_color_legend, :foreground_color_grid, :foreground_color_axis, -# :foreground_color_text, :foreground_color_border, -# :group, -# :label, -# :seriestype, -# :seriescolor, :seriesalpha, -# :linecolor, :linestyle, :linewidth, :linealpha, -# :markershape, :markercolor, :markersize, :markeralpha, -# :markerstrokewidth, :markerstrokecolor, :markerstrokealpha, -# :fillrange, :fillcolor, :fillalpha, -# :bins, -# :n, :nc, :nr, :layout, -# :smooth, -# :title, :windowtitle, :show, :size, -# :x, :xlabel, :xlims, :xticks, :xscale, :xflip, -# :y, :ylabel, :ylims, :yticks, :yscale, :yflip, -# :axis, :yrightlabel, -# :z, :zlabel, :zlims, :zticks, :zscale, :zflip, -# :z, -# :tickfont, :guidefont, :legendfont, -# :grid, :legend, :colorbar, -# :marker_z, :levels, -# :xerror, :yerror, -# :ribbon, :quiver, -# :orientation, -# :overwrite_figure, -# :polar, -# :normalize, :weights, :contours, :aspect_ratio -# ] -# supportedAxes(::PyPlotBackend) = _allAxes -# supportedTypes(::PyPlotBackend) = [ -# :none, :line, :path, :steppre, :steppost, :shape, -# :scatter, :hist2d, :hexbin, :hist, :density, -# :bar, :sticks, :box, :violin, :quiver, -# :hline, :vline, :heatmap, :pie, -# :contour, :contour3d, :path3d, :scatter3d, :surface, :wireframe -# ] -# supportedStyles(::PyPlotBackend) = [:auto, :solid, :dash, :dot, :dashdot] -# supportedMarkers(::PyPlotBackend) = vcat(_allMarkers, Shape) -# supportedScales(::PyPlotBackend) = [:identity, :ln, :log2, :log10] -# subplotSupported(::PyPlotBackend) = true -# -# -# # -------------------------------------------------------------------------------------- - -# -# -# supportedArgs(::GRBackend) = [ -# :annotation, -# :background_color, :foreground_color, :color_palette, -# :group, -# :label, -# :seriestype, -# :seriescolor, :seriesalpha, -# :linecolor, :linestyle, :linewidth, :linealpha, -# :markershape, :markercolor, :markersize, :markeralpha, -# :markerstrokewidth, :markerstrokecolor, :markerstrokealpha, -# :fillrange, :fillcolor, :fillalpha, -# :bins, -# :n, :nc, :nr, :layout, -# :smooth, -# :title, :windowtitle, :show, :size, -# :x, :xlabel, :xlims, :xticks, :xscale, :xflip, -# :y, :ylabel, :ylims, :yticks, :yscale, :yflip, -# :axis, :yrightlabel, -# :z, :zlabel, :zlims, :zticks, :zscale, :zflip, -# :z, -# :tickfont, :guidefont, :legendfont, -# :grid, :legend, :colorbar, -# :marker_z, :levels, -# :xerror, :yerror, -# :ribbon, :quiver, -# :orientation, -# :overwrite_figure, -# :polar, -# ] -# supportedAxes(::GRBackend) = _allAxes -# supportedTypes(::GRBackend) = [:none, :line, :path, :steppre, :steppost, :sticks, -# :scatter, :hist2d, :hexbin, :hist, :density, :bar, -# :hline, :vline, :contour, :heatmap, :path3d, :scatter3d, :surface, -# :wireframe, :ohlc, :pie] -# supportedStyles(::GRBackend) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot] -# supportedMarkers(::GRBackend) = vcat(_allMarkers, Shape) -# supportedScales(::GRBackend) = [:identity, :log10] -# subplotSupported(::GRBackend) = true -# -# -# # -------------------------------------------------------------------------------------- - -# -# -# supportedArgs(::QwtBackend) = [ -# :annotation, -# :axis, -# :background_color, -# :linecolor, -# :color_palette, -# :fillrange, -# :fillcolor, -# :foreground_color, -# :group, -# :label, -# :layout, -# :legend, -# :seriescolor, :seriesalpha, -# :linestyle, -# :seriestype, -# :linewidth, -# :markershape, -# :markercolor, -# :markersize, -# :n, -# :bins, -# :nc, -# :nr, -# :pos, -# :smooth, -# :show, -# :size, -# :title, -# :windowtitle, -# :x, -# :xlabel, -# :xlims, -# :xticks, -# :y, -# :ylabel, -# :ylims, -# :yrightlabel, -# :yticks, -# :xscale, -# :yscale, -# ] -# supportedTypes(::QwtBackend) = [:none, :line, :path, :steppre, :steppost, :sticks, :scatter, :hist2d, :hexbin, :hist, :bar, :hline, :vline] -# supportedMarkers(::QwtBackend) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5, :star8, :hexagon] -# supportedScales(::QwtBackend) = [:identity, :log10] -# subplotSupported(::QwtBackend) = true -# -# -# # -------------------------------------------------------------------------------------- - -# -# supportedArgs(::UnicodePlotsBackend) = [ -# # :annotation, -# # :args, -# # :axis, -# # :background_color, -# # :linecolor, -# # :fill, -# # :foreground_color, -# :group, -# # :heatmap_c, -# # :kwargs, -# :label, -# # :layout, -# :legend, -# :seriescolor, :seriesalpha, -# :linestyle, -# :seriestype, -# # :linewidth, -# :markershape, -# # :markercolor, -# # :markersize, -# # :markerstrokewidth, -# # :markerstrokecolor, -# # :markerstrokestyle, -# # :n, -# :bins, -# # :nc, -# # :nr, -# # :pos, -# # :reg, -# # :ribbon, -# :show, -# :size, -# :title, -# :windowtitle, -# :x, -# :xlabel, -# :xlims, -# # :xticks, -# :y, -# :ylabel, -# :ylims, -# # :yrightlabel, -# # :yticks, -# # :xscale, -# # :yscale, -# # :xflip, -# # :yflip, -# # :z, -# ] -# supportedAxes(::UnicodePlotsBackend) = [:auto, :left] -# supportedTypes(::UnicodePlotsBackend) = [:none, :line, :path, :steppre, :steppost, :sticks, :scatter, :hist2d, :hexbin, :hist, :bar, :hline, :vline] -# supportedStyles(::UnicodePlotsBackend) = [:auto, :solid] -# supportedMarkers(::UnicodePlotsBackend) = [:none, :auto, :ellipse] -# supportedScales(::UnicodePlotsBackend) = [:identity] -# subplotSupported(::UnicodePlotsBackend) = true -# -# -# -# -# # -------------------------------------------------------------------------------------- - -# -# supportedArgs(::WinstonBackend) = [ -# :annotation, -# # :args, -# # :axis, -# # :background_color, -# :linecolor, -# :color_palette, -# :fillrange, -# :fillcolor, -# # :foreground_color, -# :group, -# # :heatmap_c, -# # :kwargs, -# :label, -# # :layout, -# :legend, -# :seriescolor, :seriesalpha, -# :linestyle, -# :seriestype, -# :linewidth, -# :markershape, -# :markercolor, -# :markersize, -# # :markerstrokewidth, -# # :markerstrokecolor, -# # :markerstrokestyle, -# # :n, -# :bins, -# # :nc, -# # :nr, -# # :pos, -# :smooth, -# # :ribbon, -# :show, -# :size, -# :title, -# :windowtitle, -# :x, -# :xlabel, -# :xlims, -# # :xticks, -# :y, -# :ylabel, -# :ylims, -# # :yrightlabel, -# # :yticks, -# :xscale, -# :yscale, -# # :xflip, -# # :yflip, -# # :z, -# ] -# supportedAxes(::WinstonBackend) = [:auto, :left] -# supportedTypes(::WinstonBackend) = [:none, :line, :path, :sticks, :scatter, :hist, :bar] -# supportedStyles(::WinstonBackend) = [:auto, :solid, :dash, :dot, :dashdot] -# supportedMarkers(::WinstonBackend) = [:none, :auto, :rect, :ellipse, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5] -# supportedScales(::WinstonBackend) = [:identity, :log10] -# subplotSupported(::WinstonBackend) = false -# -# -# # -------------------------------------------------------------------------------------- - -# -# -# supportedArgs(::BokehBackend) = [ -# # :annotation, -# # :axis, -# # :background_color, -# :linecolor, -# # :color_palette, -# # :fillrange, -# # :fillcolor, -# # :fillalpha, -# # :foreground_color, -# :group, -# # :label, -# # :layout, -# # :legend, -# :seriescolor, :seriesalpha, -# :linestyle, -# :seriestype, -# :linewidth, -# # :linealpha, -# :markershape, -# :markercolor, -# :markersize, -# # :markeralpha, -# # :markerstrokewidth, -# # :markerstrokecolor, -# # :markerstrokestyle, -# # :n, -# # :bins, -# # :nc, -# # :nr, -# # :pos, -# # :smooth, -# # :show, -# :size, -# :title, -# # :windowtitle, -# :x, -# # :xlabel, -# # :xlims, -# # :xticks, -# :y, -# # :ylabel, -# # :ylims, -# # :yrightlabel, -# # :yticks, -# # :xscale, -# # :yscale, -# # :xflip, -# # :yflip, -# # :z, -# # :tickfont, -# # :guidefont, -# # :legendfont, -# # :grid, -# # :surface, -# # :levels, -# ] -# supportedAxes(::BokehBackend) = [:auto, :left] -# supportedTypes(::BokehBackend) = [:none, :path, :scatter] #,:steppre, :steppost, :sticks, :hist2d, :hexbin, :hist, :bar, :hline, :vline, :contour] -# supportedStyles(::BokehBackend) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot] -# supportedMarkers(::BokehBackend) = [:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5] #vcat(_allMarkers, Shape) -# supportedScales(::BokehBackend) = [:identity, :ln] #, :ln, :log2, :log10, :asinh, :sqrt] -# subplotSupported(::BokehBackend) = false -# -# -# # -------------------------------------------------------------------------------------- -# -# supportedArgs(::PlotlyBackend) = [ -# :annotation, -# # :axis, -# :background_color, -# :color_palette, -# :fillrange, -# :fillcolor, -# :fillalpha, -# :foreground_color, -# :group, -# :label, -# :layout, -# :legend, -# :seriescolor, :seriesalpha, -# :linecolor, -# :linestyle, -# :seriestype, -# :linewidth, -# :linealpha, -# :markershape, -# :markercolor, -# :markersize, -# :markeralpha, -# :markerstrokewidth, -# :markerstrokecolor, -# :markerstrokestyle, -# :n, -# :bins, -# :nc, -# :nr, -# # :pos, -# # :smooth, -# :show, -# :size, -# :title, -# :windowtitle, -# :x, -# :xlabel, -# :xlims, -# :xticks, -# :y, -# :ylabel, -# :ylims, -# # :yrightlabel, -# :yticks, -# :xscale, -# :yscale, -# :xflip, -# :yflip, -# :z, -# :marker_z, -# :tickfont, -# :guidefont, -# :legendfont, -# :grid, -# :levels, -# :xerror, -# :yerror, -# :ribbon, -# :quiver, -# :orientation, -# :polar, -# ] -# supportedAxes(::PlotlyBackend) = [:auto, :left] -# supportedTypes(::PlotlyBackend) = [:none, :line, :path, :scatter, :steppre, :steppost, -# :hist2d, :hist, :density, :bar, :contour, :surface, :path3d, :scatter3d, -# :pie, :heatmap] #,, :sticks, :hexbin, :hline, :vline] -# supportedStyles(::PlotlyBackend) = [:auto, :solid, :dash, :dot, :dashdot] -# supportedMarkers(::PlotlyBackend) = [:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, -# :pentagon, :hexagon, :octagon, :vline, :hline] #vcat(_allMarkers, Shape) -# supportedScales(::PlotlyBackend) = [:identity, :log10] #, :ln, :log2, :log10, :asinh, :sqrt] -# subplotSupported(::PlotlyBackend) = true -# stringsSupported(::PlotlyBackend) = true -# -# -# # -------------------------------------------------------------------------------------- -# -# supportedArgs(::PlotlyJSBackend) = [ -# :annotation, -# # :axis, -# :background_color, -# :color_palette, -# :fillrange, -# :fillcolor, -# :fillalpha, -# :foreground_color, -# :group, -# :label, -# :layout, -# :legend, -# :seriescolor, :seriesalpha, -# :linecolor, -# :linestyle, -# :seriestype, -# :linewidth, -# :linealpha, -# :markershape, -# :markercolor, -# :markersize, -# :markeralpha, -# :markerstrokewidth, -# :markerstrokecolor, -# :markerstrokestyle, -# :n, -# :bins, -# :nc, -# :nr, -# # :pos, -# # :smooth, -# :show, -# :size, -# :title, -# :windowtitle, -# :x, -# :xlabel, -# :xlims, -# :xticks, -# :y, -# :ylabel, -# :ylims, -# # :yrightlabel, -# :yticks, -# :xscale, -# :yscale, -# :xflip, -# :yflip, -# :z, -# :marker_z, -# :tickfont, -# :guidefont, -# :legendfont, -# :grid, -# :levels, -# :xerror, -# :yerror, -# :ribbon, -# :quiver, -# :orientation, -# :polar, -# ] -# supportedAxes(::PlotlyJSBackend) = [:auto, :left] -# supportedTypes(::PlotlyJSBackend) = [:none, :line, :path, :scatter, :steppre, :steppost, -# :hist2d, :hist, :density, :bar, :contour, :surface, :path3d, :scatter3d, -# :pie, :heatmap] #,, :sticks, :hexbin, :hline, :vline] -# supportedStyles(::PlotlyJSBackend) = [:auto, :solid, :dash, :dot, :dashdot] -# supportedMarkers(::PlotlyJSBackend) = [:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, -# :pentagon, :hexagon, :octagon, :vline, :hline] #vcat(_allMarkers, Shape) -# supportedScales(::PlotlyJSBackend) = [:identity, :log10] #, :ln, :log2, :log10, :asinh, :sqrt] -# subplotSupported(::PlotlyJSBackend) = true -# stringsSupported(::PlotlyJSBackend) = true -# -# # -------------------------------------------------------------------------------------- -# -# supportedArgs(::GLVisualizeBackend) = [ -# # :annotation, -# # :axis, -# # :background_color, -# # :color_palette, -# # :fillrange, -# # :fillcolor, -# # :fillalpha, -# # :foreground_color, -# # :group, -# # :label, -# # :layout, -# # :legend, -# # :linecolor, -# # :linestyle, -# :seriestype -# # :seriescolor, :seriesalpha, -# # :linewidth, -# # :linealpha, -# # :markershape, -# # :markercolor, -# # :markersize, -# # :markeralpha, -# # :markerstrokewidth, -# # :markerstrokecolor, -# # :markerstrokestyle, -# # :n, -# # :bins, -# # :nc, -# # :nr, -# # :pos, -# # :smooth, -# # :show, -# # :size, -# # :title, -# # :windowtitle, -# # :x, -# # :xlabel, -# # :xlims, -# # :xticks, -# # :y, -# # :ylabel, -# # :ylims, -# # :yrightlabel, -# # :yticks, -# # :xscale, -# # :yscale, -# # :xflip, -# # :yflip, -# # :z, -# # :tickfont, -# # :guidefont, -# # :legendfont, -# # :grid, -# # :surface -# # :levels, -# ] -# supportedAxes(::GLVisualizeBackend) = [:auto, :left] -# supportedTypes(::GLVisualizeBackend) = [:surface] #, :path, :scatter ,:steppre, :steppost, :sticks, :heatmap, :hexbin, :hist, :bar, :hline, :vline, :contour] -# supportedStyles(::GLVisualizeBackend) = [:auto, :solid] #, :dash, :dot, :dashdot, :dashdotdot] -# supportedMarkers(::GLVisualizeBackend) = [:none, :auto, :ellipse] #, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5] #vcat(_allMarkers, Shape) -# supportedScales(::GLVisualizeBackend) = [:identity] #, :log, :log2, :log10, :asinh, :sqrt] -# subplotSupported(::GLVisualizeBackend) = false -# -# # -------------------------------------------------------------------------------------- -# -# supportedArgs(::PGFPlotsBackend) = [ -# # :annotation, -# # :axis, -# :background_color, -# # :color_palette, -# # :fillrange, -# :fillcolor, -# :fillalpha, -# # :foreground_color, -# # :group, -# # :label, -# # :layout, -# # :legend, -# :seriescolor, :seriesalpha, -# :linecolor, -# :linestyle, -# :seriestype, -# :linewidth, -# :linealpha, -# :markershape, -# :markercolor, -# :markersize, -# :markeralpha, -# # :markerstrokewidth, -# :markerstrokecolor, -# :markerstrokestyle, -# # :n, -# # :bins, -# # :nc, -# # :nr, -# # :pos, -# # :smooth, -# # :show, -# # :size, -# :title, -# # :windowtitle, -# :x, -# :xlabel, -# :xlims, -# # :xticks, -# :y, -# :ylabel, -# :ylims, -# # :yrightlabel, -# # :yticks, -# :xscale, -# :yscale, -# :xflip, -# :yflip, -# :z, -# :zscale, -# # :tickfont, -# # :guidefont, -# # :legendfont, -# :grid, -# # :surface -# # :levels, -# ] -# supportedAxes(::PGFPlotsBackend) = [:auto, :left] -# supportedTypes(::PGFPlotsBackend) = [:path, :path3d, :scatter, :line, :steppre, :stepmid, :steppost, :hist, :bar, :hist2d, :sticks, :ysticks, :xsticks, :contour] # :hexbin, :hline, :vline,] -# supportedStyles(::PGFPlotsBackend) = [:auto, :solid, :dash, :dot, :dashdot, :dashdotdot] -# supportedMarkers(::PGFPlotsBackend) = [:none, :auto, :ellipse, :rect, :diamond, :utriangle, :dtriangle, :cross, :xcross, :star5, :pentagon] #vcat(_allMarkers, Shape) -# supportedScales(::PGFPlotsBackend) = [:identity, :log, :ln, :log2, :log10] # :asinh, :sqrt] -# subplotSupported(::PGFPlotsBackend) = false diff --git a/src/backends/template.jl b/src/backends/template.jl index 203f0aad..537903e9 100644 --- a/src/backends/template.jl +++ b/src/backends/template.jl @@ -20,10 +20,8 @@ function _create_backend_figure(plt::Plot{[PkgName]Backend}) end -function _add_series(::[PkgName]AbstractBackend, plt::Plot, d::KW) +function _add_series(plt::Plot{[PkgName]Backend}, series::Series) # TODO: add one series to the underlying package - push!(plt.seriesargs, d) - plt end function _add_annotations{X,Y,V}(plt::Plot{[PkgName]AbstractBackend}, anns::AVec{@compat(Tuple{X,Y,V})}) diff --git a/src/backends/unicodeplots.jl b/src/backends/unicodeplots.jl index f50d741a..80e7a8e1 100644 --- a/src/backends/unicodeplots.jl +++ b/src/backends/unicodeplots.jl @@ -194,14 +194,16 @@ function _create_backend_figure(plt::Plot{UnicodePlotsBackend}) # plt end -function _add_series(::UnicodePlotsBackend, plt::Plot, d::KW) +function _add_series(plt::Plot{UnicodePlotsBackend}, series::Series) + d = series.d + # TODO don't need these once the "bar" series recipe is done if d[:seriestype] in (:sticks, :bar) d = barHack(; d...) elseif d[:seriestype] == :hist d = barHack(; histogramHack(; d...)...) end - push!(plt.seriesargs, d) - plt + # push!(plt.seriesargs, d) + # plt end diff --git a/src/plot.jl b/src/plot.jl index e2305a6f..f4f1f3ef 100644 --- a/src/plot.jl +++ b/src/plot.jl @@ -142,7 +142,10 @@ function _apply_series_recipe(plt::Plot, d::KW) if st in supportedTypes() # println("adding series!!") warnOnUnsupported(plt.backend, d) - _add_series(plt.backend, plt, d) + series = Series(d) + push!(plt.series_list, series) + # _add_series(plt.backend, plt, d) + _add_series(plt, series) else # get a sub list of series for this seriestype series_list = try @@ -208,7 +211,7 @@ function _plot!(plt::Plot, d::KW, args...) # if there was a grouping, filter the data here _filter_input_data!(kw) - @show typeof((kw[:x], kw[:y], kw[:z])) + # @show typeof((kw[:x], kw[:y], kw[:z])) # map marker_z if it's a Function if isa(get(kw, :marker_z, nothing), Function) @@ -255,9 +258,9 @@ function _plot!(plt::Plot, d::KW, args...) # @show anns - for kw in kw_list - @show typeof((kw[:x], kw[:y], kw[:z])) - end + # for kw in kw_list + # @show typeof((kw[:x], kw[:y], kw[:z])) + # end # merge plot args... this is where we combine all the plot args from the user and # from the recipes... axis info, colors, etc @@ -269,9 +272,9 @@ function _plot!(plt::Plot, d::KW, args...) handlePlotColors(plt.backend, plt.plotargs) end - for kw in kw_list - @show typeof((kw[:x], kw[:y], kw[:z])) - end + # for kw in kw_list + # @show typeof((kw[:x], kw[:y], kw[:z])) + # end # this is it folks! # TODO: we probably shouldn't use i for tracking series index, but rather explicitly track it in recipes diff --git a/src/recipes.jl b/src/recipes.jl index 3b4d4889..30a8b96e 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -216,12 +216,11 @@ end # for seriestype `line`, need to sort by x values @recipe function f(::Type{Val{:line}}, x, y, z) - # order by x - indices = sortperm(d[:x]) - d[:x] = d[:x][indices] - d[:y] = d[:y][indices] - if typeof(d[:z]) <: AVec - d[:z] = d[:z][indices] + indices = sortperm(x) + d[:x] = x[indices] + d[:y] = y[indices] + if typeof(z) <: AVec + d[:z] = z[indices] end d[:seriestype] = :path () diff --git a/src/types.jl b/src/types.jl index fac40a3e..6776b358 100644 --- a/src/types.jl +++ b/src/types.jl @@ -16,6 +16,32 @@ end wrap{T}(obj::T) = InputWrapper{T}(obj) Base.isempty(wrapper::InputWrapper) = false +type AxisView + label::UTF8String + axis::Axis +end + +type Subplot + axisviews::Vector{AxisView} + subplotargs::KW # args specific to this subplot + obj # can store backend-specific data... like a pyplot ax +end + +type Series + d::KW + x + y + z + # subplots::Vector{Subplot} +end + +function Series(d::KW) + x = pop!(d, :x) + y = pop!(d, :y) + z = pop!(d, :z) + Series(d, x, y, z) +end + # ----------------------------------------------------------- # Plot # ----------------------------------------------------------- @@ -25,7 +51,9 @@ type Plot{T<:AbstractBackend} <: AbstractPlot{T} backend::T # the backend type n::Int # number of series plotargs::KW # arguments for the whole plot - seriesargs::Vector{KW} # arguments for each series + # seriesargs::Vector{KW} # arguments for each series + series_list::Vector{Series} # arguments for each series + subplots::Vector{Subplot} end # ----------------------------------------------------------- @@ -38,18 +66,18 @@ abstract SubplotLayout # Subplot # ----------------------------------------------------------- -type Subplot{T<:AbstractBackend, L<:SubplotLayout} <: AbstractPlot{T} - o # the underlying object - plts::Vector{Plot{T}} # the individual plots - backend::T - p::Int # number of plots - n::Int # number of series - layout::L - plotargs::KW - initialized::Bool - linkx::Bool - linky::Bool - linkfunc::Function # maps (row,column) -> (BoolOrNothing, BoolOrNothing)... if xlink/ylink are nothing, then use subplt.linkx/y -end +# type Subplot{T<:AbstractBackend, L<:SubplotLayout} <: AbstractPlot{T} +# o # the underlying object +# plts::Vector{Plot{T}} # the individual plots +# backend::T +# p::Int # number of plots +# n::Int # number of series +# layout::L +# plotargs::KW +# initialized::Bool +# linkx::Bool +# linky::Bool +# linkfunc::Function # maps (row,column) -> (BoolOrNothing, BoolOrNothing)... if xlink/ylink are nothing, then use subplt.linkx/y +# end # -----------------------------------------------------------------------