Added an extrema(plt) which return the tuple (xmin, xmax), and changed abline! to use extrema.
This commit is contained in:
parent
5c4526725b
commit
1963fe208e
@ -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...)
|
||||
@ -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))
|
||||
Loading…
x
Reference in New Issue
Block a user