From e8ed79a6bbdb88279c9a7134cd39bd418c7b1079 Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Tue, 29 Mar 2016 11:01:16 -0600 Subject: [PATCH] pyplot zlim fixes --- src/backends/pyplot.jl | 37 +++++++++++++++++++------------------ 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/backends/pyplot.jl b/src/backends/pyplot.jl index 04bf852d..598c2345 100644 --- a/src/backends/pyplot.jl +++ b/src/backends/pyplot.jl @@ -550,7 +550,7 @@ function set_lims!(plt::Plot{PyPlotBackend}, axis::Symbol) if plt.plotargs[:ylims] == :auto ax[:set_ylim](minmaxseries(plt.seriesargs, :y, axis)...) end - if plt.plotargs[:zlims] == :auto + if plt.plotargs[:zlims] == :auto && haskey(ax, :set_zlim) ax[:set_zlim](minmaxseries(plt.seriesargs, :z, axis)...) end end @@ -577,25 +577,25 @@ end # ----------------------------------------------------------------- -function addPyPlotLims(ax, lims, what) - lims == :auto && return - ltype = limsType(lims) - if ltype == :limits - if what == :xlim - isfinite(lims[1]) && ax[:set_xlim](left = lims[1]) - isfinite(lims[2]) && ax[:set_xlim](right = lims[2]) - elseif what == :ylim - isfinite(lims[1]) && ax[:set_ylim](bottom = lims[1]) - isfinite(lims[2]) && ax[:set_ylim](top = lims[2]) - elseif what == :zlim - isfinite(lims[1]) && ax[:set_zlim](bottom = lims[1]) - isfinite(lims[2]) && ax[:set_zlim](top = lims[2]) +function addPyPlotLims(ax, lims, dimension) + lims == :auto && return + ltype = limsType(lims) + if ltype == :limits + if dimension == :xlim + isfinite(lims[1]) && ax[:set_xlim](left = lims[1]) + isfinite(lims[2]) && ax[:set_xlim](right = lims[2]) + elseif dimension == :ylim + isfinite(lims[1]) && ax[:set_ylim](bottom = lims[1]) + isfinite(lims[2]) && ax[:set_ylim](top = lims[2]) + elseif dimension == :zlim && haskey(ax, :set_zlim) + isfinite(lims[1]) && ax[:set_zlim](bottom = lims[1]) + isfinite(lims[2]) && ax[:set_zlim](top = lims[2]) + else + error("Invalid argument at position 3: $dimension") + end else - error("Invalid argument at position 3: $what") + error("Invalid input for $dimension: ", lims) end - else - error("Invalid input for $what: ", lims) - end end function addPyPlotTicks(ax, ticks, isx::Bool) @@ -622,6 +622,7 @@ function _update_plot(plt::Plot{PyPlotBackend}, d::KW) ax = getLeftAxis(figorax) # PyPlot.sca(ax) + # title and axis labels # haskey(d, :title) && PyPlot.title(d[:title]) haskey(d, :title) && ax[:set_title](d[:title])