R's abline draws a straight line parameterised by y = ax+b
on the x-y 2D coordinate plan.
What's Julia's equivalent of that in Plots.jl?
There is Plots.abline!
which draws a straight line in the form of ax+b
respecting axis limits of the plot. So it will not actually go to infinity but does not require you to know what the axis limits are beforehand.
plot(x->((x^2+3x+2)/(x-2)), 6, 30, xlim=(6,30), size=(300,300))
# draw oblique asymptote to the above function (y=x+5)
Plots.abline!(1, 5, line=:dash)
You can also plot a straight line using only two points that are on the line. This should also respect the axis limits.
plot!([x1, x2], [y1, y2], seriestype = :straightline, kwargs...)