From 54923c082ccb0061ef04c43c152dfd52a7a58a91 Mon Sep 17 00:00:00 2001 From: Thomas Breloff Date: Tue, 27 Sep 2016 12:51:20 -0400 Subject: [PATCH] reset_extrema; setxyz for z matrix --- src/axes.jl | 15 +++++++++++++++ src/utils.jl | 16 +++++++++------- 2 files changed, 24 insertions(+), 7 deletions(-) diff --git a/src/axes.jl b/src/axes.jl index b0f3f1ef..4a797561 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -224,6 +224,21 @@ end # ------------------------------------------------------------------------- + +function reset_extrema!(sp::Subplot) + # axis = sp[Symbol(asym,:axis)] + # axis[:extrema] = Extrema() + for asym in (:x,:y,:z) + sp[Symbol(asym,:axis)][:extrema] = Extrema() + end + for series in sp.series_list + @show series + # expand_extrema!(axis, series[asym]) + expand_extrema!(sp, series.d) + end +end + + function expand_extrema!(ex::Extrema, v::Number) ex.emin = min(v, ex.emin) ex.emax = max(v, ex.emax) diff --git a/src/utils.jl b/src/utils.jl index d5a7757d..379a89cc 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -660,26 +660,28 @@ function setxy!{X,Y}(plt::Plot, xy::Tuple{X,Y}, i::Integer) series = plt.series_list[i] series.d[:x], series.d[:y] = xy sp = series.d[:subplot] - expand_extrema!(sp.attr[:xaxis], xy[1]) - expand_extrema!(sp.attr[:yaxis], xy[2]) + reset_extrema!(sp) _series_updated(plt, series) end function setxyz!{X,Y,Z}(plt::Plot, xyz::Tuple{X,Y,Z}, i::Integer) series = plt.series_list[i] series.d[:x], series.d[:y], series.d[:z] = xyz sp = series.d[:subplot] - expand_extrema!(sp.attr[:xaxis], xyz[1]) - expand_extrema!(sp.attr[:yaxis], xyz[2]) - expand_extrema!(sp.attr[:zaxis], xyz[3]) + reset_extrema!(sp) _series_updated(plt, series) end +function setxyz!{X,Y,Z<:AbstractMatrix}(plt::Plot, xyz::Tuple{X,Y,Z}, i::Integer) + setxyz!(plt, (xyz[1], xyz[2], Surface(xyz[3])), i) +end + + # ------------------------------------------------------- # indexing notation # Base.getindex(plt::Plot, i::Integer) = getxy(plt, i) -Base.setindex!{X,Y}(plt::Plot, xy::Tuple{X,Y}, i::Integer) = setxy!(plt, xy, i) -Base.setindex!{X,Y,Z}(plt::Plot, xyz::Tuple{X,Y,Z}, i::Integer) = setxyz!(plt, xyz, i) +Base.setindex!{X,Y}(plt::Plot, xy::Tuple{X,Y}, i::Integer) = (setxy!(plt, xy, i); plt) +Base.setindex!{X,Y,Z}(plt::Plot, xyz::Tuple{X,Y,Z}, i::Integer) = (setxyz!(plt, xyz, i); plt) # -------------------------------------------------------