Given that I have already made a plot using, say pl = plot([1,2,3])
, is there a way to query what the current x and y limits of the plot are?
E.g. something like pl.xlims
which would return (1.0,3.0)
.
I often find myself wanting to plot something abstract along with actual data, and this would be helpful for doing that while keeping the graph nice-looking. For example, I may be performing a numerical experiment and I want to plot step size vs error. To check the order convergence, I also want to plot lines of slopes 1, 2, 3, … (in log10 scale). But if I just do something like plot!(step_sizes, step_sizes .^ 4)
, the line extends way past my data, making the window zoom out a lot more. If I knew the xlims and ylims when plotting, I could prevent this.
Alternatively, if there is some sort of option to plot new data without adjusting the plot limits, e.g. pl = plot([1,2,3]); plot!(pl, [1,2,3,4,5,6], adjust_lims=false)
, and the second half of the second series just wouldn’t be visible in the window, that would also solve my problem.