diff --git a/src/args.jl b/src/args.jl index e2586610..51747abd 100644 --- a/src/args.jl +++ b/src/args.jl @@ -371,6 +371,9 @@ const _suppress_warnings = Set{Symbol}([ :x_discrete_indices, :y_discrete_indices, :z_discrete_indices, + :x_extent_data, + :y_extent_data, + :z_extent_data, :subplot, :subplot_index, :series_plotindex, diff --git a/src/axes.jl b/src/axes.jl index c1dcff2c..f0856822 100644 --- a/src/axes.jl +++ b/src/axes.jl @@ -318,11 +318,16 @@ function expand_extrema!(sp::Subplot, d::KW) # first expand for the data for letter in (:x, :y, :z) - data = d[if vert + letter_ = if vert letter else letter == :x ? :y : letter == :y ? :x : :z - end] + end + + extent_key = Symbol(letter_, :_extent_data) + # if there is extent_key, use it for calculating limits. + data = get(d, extent_key, d[letter_]) + axis = sp[Symbol(letter, "axis")] if isa(data, Volume) diff --git a/src/recipes.jl b/src/recipes.jl index 5eab486f..bee94310 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -80,11 +80,14 @@ end @recipe function f(::Type{Val{:hline}}, x, y, z) xmin, xmax = hvline_limits(plotattributes[:subplot][:xaxis]) + span = xmax - xmin n = length(y) - newx = repmat(Float64[xmin, xmax, NaN], n) + newx = repmat(Float64[xmin-10span, xmax+10span, NaN], n) newy = vec(Float64[yi for i=1:3,yi=y]) x := newx y := newy + x_extent_data := Float64[] + y_extent_data := newy seriestype := :path () end @@ -92,11 +95,14 @@ end @recipe function f(::Type{Val{:vline}}, x, y, z) ymin, ymax = hvline_limits(plotattributes[:subplot][:yaxis]) + span = ymax - ymin n = length(y) newx = vec(Float64[yi for i=1:3,yi=y]) - newy = repmat(Float64[ymin, ymax, NaN], n) + newy = repmat(Float64[ymin-10span, ymax+10span, NaN], n) x := newx y := newy + x_extent_data := newx + y_extent_data := Float64[] seriestype := :path () end @@ -987,9 +993,11 @@ end "Adds a+bx... straight line over the current plot, without changing the axis limits" function abline!(plt::Plot, a, b; kw...) - xl, yl = xlims(plt), ylims(plt) - x1, x2 = max(xl[1], (yl[1] - b)/a), min(xl[2], (yl[2] - b)/a) - plot!(plt, x -> b + a*x, x1, x2; kw...) + xmin, xmax = xlims(plt) + span = xmax - xmin + xmin, xmax = (xmin - 10span, xmax + 10span) + f(x) = b + a*x + plot!(plt, [(xmin, f(xmin)), (xmax, f(xmax))]; x_extent_data = Float64[], y_extent_data = Float64[], kw...) end abline!(args...; kw...) = abline!(current(), args...; kw...)