I'm working with the axes objects for a pyplot chart.
What I am trying to do is have the the minimum size for the y-axis, such that the lower end of the axis cannot go above -1 and the upper end of the axis cannot go below 1, but I don't want to constrain an upper bound of the upper end of the axis, and a lower bound for the lower bound of the axis.
Is there a way where I can set the minimum upper bound of the axis and the reverse for the lower one?
So once you perform a plot, just query the axes for the current limits, and extend them if needed. Something like this:
ylim = axes.get_ylim()
new_ylim = (min(ylim[0],-1), max(ylim[1], 1) )
axes.set_ylim(new_ylim)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With