diff --git a/src/recipes.jl b/src/recipes.jl index 45309c12..adf59872 100644 --- a/src/recipes.jl +++ b/src/recipes.jl @@ -132,7 +132,7 @@ end "Adds a+bx... straight line over the current plot" function abline!(plt::Plot, a, b; kw...) - plot!(plt, [xmin(plt), xmax(plt)], x -> b + a*x; kw...) + plot!(plt, [extrema(plt)...], x -> b + a*x; kw...) end -abline!(args...; kw...) = abline!(current(), args...; kw...) +abline!(args...; kw...) = abline!(current(), args...; kw...) \ No newline at end of file diff --git a/src/utils.jl b/src/utils.jl index 576f4970..90431042 100644 --- a/src/utils.jl +++ b/src/utils.jl @@ -471,3 +471,5 @@ xmin(plt::Plot) = minimum([minimum(d[:x]) for d in plt.seriesargs]) "Largest x in plot" xmax(plt::Plot) = maximum([maximum(d[:x]) for d in plt.seriesargs]) +"Extrema of x-values in plot" +Base.extrema(plt::Plot) = (xmin(plt), xmax(plt)) \ No newline at end of file