From ed7cc9b89e6b90c19c187dea108f8c5722804ef8 Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Wed, 23 Dec 2015 22:15:13 -0500 Subject: [PATCH] pyplot surface/wireframe fix for matrix x/y; fix in with, when backend unset --- src/backends/pyplot.jl | 12 ++++++++++-- src/utils.jl | 3 +++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index d433eb49..f150c74b 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -344,7 +344,15 @@ function _add_series(pkg::PyPlotPackage, plt::Plot; kw...) end handle elseif lt in (:surface,:wireframe) - plotfunc(repmat(d[:x]',length(d[:y]),1), repmat(d[:y],1,length(d[:x])), d[:z].surf'; extra_kwargs...) + x, y, z = if isa(d[:x], AMat) && isa(d[:y], AMat) + d[:x], d[:y], d[:z].surf + else + repmat(d[:x]',length(d[:y]),1), repmat(d[:y],1,length(d[:x])), d[:z].surf' + end + # x = isa(d[:x], AMat) ? d[:x] : repmat(d[:x]',length(d[:y]),1) + # y = isa(d[:y], AMat) ? d[:y] : repmat(d[:y],1,length(d[:x])) + # z = isa(d[:x], AMat) ? d[:z].surf : d[:z].surf' + plotfunc(x, y, z; extra_kwargs...) elseif lt in _3dTypes plotfunc(d[:x], d[:y], d[:z]; extra_kwargs...) elseif lt in (:scatter, :heatmap, :hexbin) @@ -629,7 +637,7 @@ end function addPyPlotLegend(plt::Plot, ax) if plt.plotargs[:legend] # gotta do this to ensure both axes are included - args = filter(x -> !(x[:linetype] in (:hist,:density,:hexbin,:heatmap,:hline,:vline,:contour, :path3d, :scatter3d)), plt.seriesargs) + args = filter(x -> !(x[:linetype] in (:hist,:density,:hexbin,:heatmap,:hline,:vline,:contour, :surface, :wireframe, :path3d, :scatter3d)), plt.seriesargs) if length(args) > 0 leg = ax[:legend]([d[:serieshandle] for d in args], [d[:label] for d in args], diff --git a/src/utils.jl b/src/utils.jl index 167910b4..d8880e6e 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -226,6 +226,9 @@ function with(f::Function, args...; kw...) end # save the backend + if CURRENT_BACKEND.sym == :none + pickDefaultBackend() + end oldbackend = CURRENT_BACKEND.sym for arg in args