Closed IanButterworth closed 8 months ago
Good point and idea for enhancement, I'll have a look soon.
The underlying problem is that limits are a Canvas
property, and not a Plot
feature.
I've modified the code slightly in https://github.com/JuliaPlots/UnicodePlots.jl/pull/366 to allow something like this, which is an enhancement over the current, but not quite what you want:
p = Plot(xlim=(-1, 2), ylim=(3, 10)) # set the limits beforehand
for x in y
lineplot!(plt, some_x, some_y)
end
display(plt)
I have thought about this, and I don't think this will be easily implemented, because we draw on a fixed canvas.
However, one can set the limits beforehand as exposed in https://github.com/JuliaPlots/UnicodePlots.jl/issues/365#issuecomment-1867564480.
I find it's common to
But this will end up with a plot with lims -1 1 even though there has been real data added to it.
It seems fair that the limits shouldn't auto change, but maybe there could be a
autolims!(plt)
function to call before display?Otherwise I need to manually track the extrema of my data and set lims manually at the end.