From f5ee5ea8148f92ebc8242a41b7e920f7e2933ee2 Mon Sep 17 00:00:00 2001 From: Darwin Darakananda Date: Wed, 4 Oct 2017 14:26:35 -0700 Subject: [PATCH 1/3] Fix `line_z` for PyPlot backend `LineCollection` expects an array with pairs of coordinates, corresponding to the starting and ending points of each segment. --- src/backends/pyplot.jl | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index ea0ba6c7..12442aec 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -508,11 +508,12 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) handle = if is3d(st) for rng in iter_segments(x, y, z) length(rng) < 2 && continue - push!(segments, [(_cycle(x,i),_cycle(y,i),_cycle(z,i)) for i in rng]) + for i in rng[1:end-1] + push!(segments, [(_cycle(x,i),_cycle(y,i),_cycle(z,i)), + (_cycle(x,i+1),_cycle(y,i+1),_cycle(z,i+1))]) + end end - # for i=1:n - # segments[i] = [(_cycle(x,i), _cycle(y,i), _cycle(z,i)), (_cycle(x,i+1), _cycle(y,i+1), _cycle(z,i+1))] - # end + lc = pyart3d["Line3DCollection"](segments; kw...) lc[:set_array](lz) ax[:add_collection3d](lc, zs=z) #, zdir='y') @@ -520,11 +521,11 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) else for rng in iter_segments(x, y) length(rng) < 2 && continue - push!(segments, [(_cycle(x,i),_cycle(y,i)) for i in rng]) + for i in rng[1:end-1] + push!(segments, [(_cycle(x,i),_cycle(y,i)), (_cycle(x,i+1),_cycle(y,i+1))]) + end end - # for i=1:n - # segments[i] = [(_cycle(x,i), _cycle(y,i)), (_cycle(x,i+1), _cycle(y,i+1))] - # end + lc = pycollections["LineCollection"](segments; kw...) lc[:set_array](lz) ax[:add_collection](lc) From 514cd1bd3735c63d8642a044c2a3a048c492501b Mon Sep 17 00:00:00 2001 From: Darwin Darakananda Date: Wed, 4 Oct 2017 15:10:36 -0700 Subject: [PATCH 2/3] normalize colors even when plotting without colorbars --- src/backends/pyplot.jl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 12442aec..9918ec08 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -499,11 +499,9 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) :zorder => plt.n, :cmap => py_linecolormap(series), :linewidth => py_dpi_scale(plt, series[:linewidth]), - :linestyle => py_linestyle(st, series[:linestyle]) + :linestyle => py_linestyle(st, series[:linestyle]), + :norm => pycolors["Normalize"](; extrakw...) ) - if needs_colorbar - kw[:norm] = pycolors["Normalize"](; extrakw...) - end lz = collect(series[:line_z]) handle = if is3d(st) for rng in iter_segments(x, y, z) From 16d18552f85c2c45b71bd55f8524f4c05eed2bd4 Mon Sep 17 00:00:00 2001 From: Darwin Darakananda Date: Thu, 5 Oct 2017 20:49:17 -0700 Subject: [PATCH 3/3] Allow `line_z` to specify color across multiple lines --- src/backends/pyplot.jl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 9918ec08..c42f6547 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -502,7 +502,7 @@ function py_add_series(plt::Plot{PyPlotBackend}, series::Series) :linestyle => py_linestyle(st, series[:linestyle]), :norm => pycolors["Normalize"](; extrakw...) ) - lz = collect(series[:line_z]) + lz = _cycle(series[:line_z], 1:n) handle = if is3d(st) for rng in iter_segments(x, y, z) length(rng) < 2 && continue