Let abline plot outside extent
This commit is contained in:
parent
45e0aaacb4
commit
d8a827b98e
@ -993,9 +993,11 @@ end
|
|||||||
|
|
||||||
"Adds a+bx... straight line over the current plot, without changing the axis limits"
|
"Adds a+bx... straight line over the current plot, without changing the axis limits"
|
||||||
function abline!(plt::Plot, a, b; kw...)
|
function abline!(plt::Plot, a, b; kw...)
|
||||||
xl, yl = xlims(plt), ylims(plt)
|
xmin, xmax = xlims(plt)
|
||||||
x1, x2 = max(xl[1], (yl[1] - b)/a), min(xl[2], (yl[2] - b)/a)
|
span = xmax - xmin
|
||||||
plot!(plt, x -> b + a*x, x1, x2; kw...)
|
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
|
end
|
||||||
|
|
||||||
abline!(args...; kw...) = abline!(current(), args...; kw...)
|
abline!(args...; kw...) = abline!(current(), args...; kw...)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user