From 6161b08f82b9d86bf8eb1b5a82f9c683c5467f44 Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Fri, 22 Apr 2016 12:53:40 -0400 Subject: [PATCH] working on pyplot refactor; path/scatter in 2d/3d done --- src/args.jl | 2 +- src/backends/pyplot.jl | 23 ++++++++++++----------- src/backends/supported.jl | 11 +++++++++++ 3 files changed, 24 insertions(+), 12 deletions(-) diff --git a/src/args.jl b/src/args.jl index 13cd004d..360ea0da 100644 --- a/src/args.jl +++ b/src/args.jl @@ -826,7 +826,7 @@ function getSeriesArgs(pkg::AbstractBackend, plotargs::KW, kw, commandIndex::Int d[:markerstrokecolor] = c # update alphas - for asym in (:linealpha, :markeralpha, :fillalpha) + for asym in (:linealpha, :markeralpha, :markerstrokealpha, :fillalpha) if d[asym] == nothing d[asym] = d[:seriesalpha] end diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index e8f690ac..bfbbdcc1 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -325,7 +325,7 @@ end # total hack due to PyPlot bug (see issue #145). # hack: duplicate the color vector when the total rgba fields is the same as the series length -function color_fix(c) +function color_fix(c, x) if (typeof(c) <: AbstractArray && length(c)*4 == length(x)) || (typeof(c) <: Tuple && length(x) == 4) vcat(c, c) @@ -392,18 +392,17 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) # :shape => :add_patch, # # do the plotting - if lt in (:path, :line, :scatter) + + # path/line/scatter should all do UP TO 2 series... a line, and a scatter + if lt in (:path, :line, :scatter, :path3d, :scatter3d) + xyargs = (lt in _3dTypes ? (x,y,z) : (x,y)) + if d[:linewidth] > 0 - d[:serieshandle] = ax[:plot](x, y; + d[:serieshandle] = ax[:plot](xyargs...; color = pylinecolor(d), linewidth = d[:linewidth], linestyle = getPyPlotLineStyle(lt, d[:linestyle]), drawstyle = getPyPlotStepStyle(lt), - # marker = markershape, - # markersize = d[:markersize], - # markerfacecolor = markercolor, - # markeredgecolor = strokecolor, - # markeredgewidth = d[:markerstrokewidth], label = d[:label], zorder = plt.n ) @@ -411,12 +410,12 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) if d[:markershape] != :none if d[:marker_z] == nothing - extrakw[:c] = color_fix(pymarkercolor(d)) + extrakw[:c] = color_fix(pymarkercolor(d), x) else extrakw[:c] = convert(Vector{Float64}, d[:marker_z]) extrakw[:cmap] = pymarkercolormap(d) end - d[:serieshandle] = ax[:scatter](x, y; + d[:serieshandle] = ax[:scatter](xyargs...; marker = getPyPlotMarker(d[:markershape]), s = d[:markersize] .^ 2, edgecolors = pymarkerstrokecolor(d), @@ -426,7 +425,6 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) extrakw... ) end - end # smoothing @@ -712,6 +710,9 @@ end # -------------------------------------------------------------------------- +# TODO: d[:serieshandle] should really be a list of handles... then we should set +# the x/y data for each handle (for example, plot and scatter) + function setxy!{X,Y}(plt::Plot{PyPlotBackend}, xy::Tuple{X,Y}, i::Integer) d = plt.seriesargs[i] d[:x], d[:y] = xy diff --git a/src/backends/supported.jl b/src/backends/supported.jl index 8ab87645..282918a5 100644 --- a/src/backends/supported.jl +++ b/src/backends/supported.jl @@ -25,6 +25,7 @@ supportedArgs(::GadflyBackend) = [ :group, :label, :linetype, + :seriescolor, :seriesalpha, :linecolor, :linestyle, :linewidth, :linealpha, :markershape, :markercolor, :markersize, :markeralpha, :markerstrokewidth, :markerstrokecolor, :markerstrokealpha, @@ -78,6 +79,7 @@ supportedArgs(::PyPlotBackend) = [ :group, :label, :linetype, + :seriescolor, :seriesalpha, :linecolor, :linestyle, :linewidth, :linealpha, :markershape, :markercolor, :markersize, :markeralpha, :markerstrokewidth, :markerstrokecolor, :markerstrokealpha, @@ -132,6 +134,7 @@ supportedArgs(::GRBackend) = [ :layout, :legend, :colorbar, + :seriescolor, :seriesalpha, :linestyle, :linetype, :linewidth, @@ -213,6 +216,7 @@ supportedArgs(::QwtBackend) = [ :label, :layout, :legend, + :seriescolor, :seriesalpha, :linestyle, :linetype, :linewidth, @@ -271,6 +275,7 @@ supportedArgs(::UnicodePlotsBackend) = [ :label, # :layout, :legend, + :seriescolor, :seriesalpha, :linestyle, :linetype, # :linewidth, @@ -335,6 +340,7 @@ supportedArgs(::WinstonBackend) = [ :label, # :layout, :legend, + :seriescolor, :seriesalpha, :linestyle, :linetype, :linewidth, @@ -396,6 +402,7 @@ supportedArgs(::BokehBackend) = [ # :label, # :layout, # :legend, + :seriescolor, :seriesalpha, :linestyle, :linetype, :linewidth, @@ -461,6 +468,7 @@ supportedArgs(::PlotlyBackend) = [ :label, :layout, :legend, + :seriescolor, :seriesalpha, :linecolor, :linestyle, :linetype, @@ -537,6 +545,7 @@ supportedArgs(::PlotlyJSBackend) = [ :label, :layout, :legend, + :seriescolor, :seriesalpha, :linecolor, :linestyle, :linetype, @@ -615,6 +624,7 @@ supportedArgs(::GLVisualizeBackend) = [ # :linecolor, # :linestyle, :linetype + # :seriescolor, :seriesalpha, # :linewidth, # :linealpha, # :markershape, @@ -677,6 +687,7 @@ supportedArgs(::PGFPlotsBackend) = [ # :label, # :layout, # :legend, + # :seriescolor, :seriesalpha, # :linecolor, # :linestyle, # :linetype,