I want to set a requirement that the minimum limit of the y-axis be greater than or equal to 0. I do not want to set the minimum limit of the y-axis to be exactly 0.
I do not want to set the y-axis minimum limit to 0 because the plot would be as follows:
I want to require the y-axis minimum limit to be greater than or equal to 0 while not setting it exactly to 0 so that the plot can look as follows:
So, what should I do instead of the following?
axes = matplotlib.pyplot.gca()
axes.xaxis.set_major_formatter(FormatStrFormatter("%.0f"))
axes.yaxis.set_major_formatter(FormatStrFormatter("%.0f"))
axes.set_xlim(left = 0)
axes.set_ylim(bottom = 0)
Use get_xlim
and get_ylim
to get the auto generated limits. Then take the max of the lower bound and 0 and use that in set_xlim
and set_ylim
.