From 242cbe5ecbf7f583fa5ee9eb2b00a3ed4a324852 Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Wed, 11 Nov 2015 17:46:44 -0500 Subject: [PATCH] z/zcolor --- docs/example_generation.jl | 6 +++--- src/args.jl | 4 ++-- src/backends/gadfly.jl | 6 +++--- src/backends/pyplot.jl | 11 ++++++----- src/backends/supported.jl | 2 ++ 5 files changed, 16 insertions(+), 13 deletions(-) diff --git a/docs/example_generation.jl b/docs/example_generation.jl index 0047a324..6d98a251 100644 --- a/docs/example_generation.jl +++ b/docs/example_generation.jl @@ -46,7 +46,7 @@ const examples = PlotExample[ [ :(y = rand(100)), :(plot(0:10:100,rand(11,4),lab="lines",w=3, palette=:grays, fill=(0.5,:auto))), - :(scatter!(y, z=abs(y-.5), m=(10,:heat), lab="grad")) + :(scatter!(y, zcolor=abs(y-.5), m=(:heat,0.8,stroke(3,:green)), ms=10*abs(y-0.5)+3, lab="grad")) ]), PlotExample("Global", "Change the guides/background/limits/ticks. Convenience args `xaxis` and `yaxis` allow you to pass a tuple or value which will be mapped to the relevant args automatically. The `xaxis` below will be replaced with `xlabel` and `xlims` args automatically during the preprocessing step. You can also use shorthand functions: `title!`, `xaxis!`, `yaxis!`, `xlabel!`, `ylabel!`, `xlims!`, `ylims!`, `xticks!`, `yticks!`", @@ -78,7 +78,7 @@ const examples = PlotExample[ PlotExample("Heatmaps", "", [ - :(heatmap(randn(10000),randn(10000), nbins=100)) + :(heatmap(randn(10000),randn(10000), nbins=20)) ]), PlotExample("Line types", "", @@ -112,7 +112,7 @@ const examples = PlotExample[ PlotExample("Histogram", "", [ - :(histogram(randn(1000), nbins=50)) + :(histogram(randn(1000), nbins=20)) ]), PlotExample("Subplots", """ diff --git a/src/args.jl b/src/args.jl index d451a34d..3b109443 100644 --- a/src/args.jl +++ b/src/args.jl @@ -138,8 +138,8 @@ _seriesDefaults[:nbins] = 30 # number of bins for heatma _seriesDefaults[:smooth] = false # regression line? _seriesDefaults[:group] = nothing # groupby vector _seriesDefaults[:annotation] = nothing # annotation tuple(s)... (x,y,annotation) -_seriesDefaults[:z] = nothing # depth for contour, color scale, etc -_seriesDefaults[:z] +_seriesDefaults[:z] = nothing # depth for contour, surface, etc +_seriesDefaults[:zcolor] = nothing # value for color scale _seriesDefaults[:surface] = nothing _seriesDefaults[:nlevels] = 15 diff --git a/src/backends/gadfly.jl b/src/backends/gadfly.jl index 9408ce2d..31987566 100644 --- a/src/backends/gadfly.jl +++ b/src/backends/gadfly.jl @@ -157,9 +157,9 @@ function addGadflyMarker!(plt::Plot, numlayers::Int, d::Dict, plotargs::Dict, ge kwargs = Dict() # handle continuous color scales for the markers - z = d[:z] - if z != nothing && typeof(z) <: AVec - kwargs[:color] = z + zcolor = d[:zcolor] + if zcolor != nothing && typeof(zcolor) <: AVec + kwargs[:color] = zcolor if !isa(d[:markercolor], ColorGradient) d[:markercolor] = colorscheme(:bluesreds) end diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index f65d4c0f..a91effa2 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -256,10 +256,10 @@ function _add_series(pkg::PyPlotPackage, plt::Plot; kw...) extra_kwargs[:marker] = getPyPlotMarker(d[:markershape]) if lt in (:scatter, :scatter3d) - extra_kwargs[:s] = d[:markersize]^2 + extra_kwargs[:s] = d[:markersize].^2 c = d[:markercolor] - if isa(c, ColorGradient) && d[:z] != nothing - extra_kwargs[:c] = convert(Vector{Float64}, d[:z]) + if isa(c, ColorGradient) && d[:zcolor] != nothing + extra_kwargs[:c] = convert(Vector{Float64}, d[:zcolor]) extra_kwargs[:cmap] = getPyPlotColorMap(c, d[:markeralpha]) else extra_kwargs[:c] = getPyPlotColor(c, d[:markeralpha]) @@ -290,6 +290,7 @@ function _add_series(pkg::PyPlotPackage, plt::Plot; kw...) extra_kwargs[:linewidth] = d[:linewidth] end extra_kwargs[:label] = d[:label] + extra_kwargs[:zorder] = plt.n end # do the plot @@ -329,9 +330,9 @@ function _add_series(pkg::PyPlotPackage, plt::Plot; kw...) if fillrange != nothing && lt != :contour fillcolor = getPyPlotColor(d[:fillcolor], d[:fillalpha]) if typeof(fillrange) <: @compat(Union{Real, AVec}) - ax[:fill_between](d[:x], fillrange, d[:y], facecolor = fillcolor) + ax[:fill_between](d[:x], fillrange, d[:y], facecolor = fillcolor, zorder = plt.n) else - ax[:fill_between](d[:x], fillrange..., facecolor = fillcolor) + ax[:fill_between](d[:x], fillrange..., facecolor = fillcolor, zorder = plt.n) end end diff --git a/src/backends/supported.jl b/src/backends/supported.jl index fc187896..45af2247 100644 --- a/src/backends/supported.jl +++ b/src/backends/supported.jl @@ -48,6 +48,7 @@ supportedArgs(::GadflyPackage) = [ :xflip, :yflip, :z, + :zcolor, :tickfont, :guidefont, :legendfont, @@ -123,6 +124,7 @@ supportedArgs(::PyPlotPackage) = [ :xflip, :yflip, :z, + :zcolor, # only supported for scatter/scatter3d :tickfont, :guidefont, :legendfont,