From b9d20142a25f6229f2dc1d26d546fdeb84719e03 Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Tue, 26 Apr 2016 14:20:07 -0400 Subject: [PATCH] pyplot trisurface support --- src/backends/pyplot.jl | 53 ++++++++++++++++++++++++++++-------------- 1 file changed, 35 insertions(+), 18 deletions(-) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 082e704b..fc74d01f 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -492,26 +492,43 @@ function _add_series(pkg::PyPlotBackend, plt::Plot, d::KW) end if lt in (:surface, :wireframe) - x, y, z = map(Array, (x,y,z)) - if !ismatrix(x) || !ismatrix(y) - x = repmat(x', length(y), 1) - y = repmat(y, 1, length(d[:x])) - z = z' - end - if lt == :surface - extrakw[:cmap] = pyfillcolormap(d) + if typeof(z) <: AbstractMatrix + x, y, z = map(Array, (x,y,z)) + if !ismatrix(x) || !ismatrix(y) + x = repmat(x', length(y), 1) + y = repmat(y, 1, length(d[:x])) + z = z' + end + if lt == :surface + extrakw[:cmap] = pyfillcolormap(d) + needs_colorbar = true + end + handle = ax[lt == :surface ? :plot_surface : :plot_wireframe](x, y, z; + label = d[:label], + zorder = plt.n, + rstride = 1, + cstride = 1, + linewidth = d[:linewidth], + edgecolor = pylinecolor(d), + extrakw... + ) + push!(handles, handle) + + elseif typeof(z) <: AbstractVector + # tri-surface plot (http://matplotlib.org/mpl_toolkits/mplot3d/tutorial.html#tri-surface-plots) + handle = ax[:plot_trisurf](x, y, z; + label = d[:label], + zorder = plt.n, + cmap = pyfillcolormap(d), + linewidth = d[:linewidth], + edgecolor = pylinecolor(d) + ) + push!(handles, handle) needs_colorbar = true + else + error("Unsupported z type $(typeof(z)) for linetype=$lt") end - handle = ax[lt == :surface ? :plot_surface : :plot_wireframe](x, y, z; - label = d[:label], - zorder = plt.n, - rstride = 1, - cstride = 1, - linewidth = d[:linewidth], - edgecolor = pylinecolor(d), - extrakw... - ) - push!(handles, handle) + end if lt == :heatmap