W3cubDocs

/Matplotlib 3.1

matplotlib.pyplot.ylim

matplotlib.pyplot.ylim(*args, **kwargs) [source]

Get or set the y-limits of the current axes.

Call signatures:

bottom, top = ylim()  # return the current ylim
ylim((bottom, top))   # set the ylim to bottom, top
ylim(bottom, top)     # set the ylim to bottom, top

If you do not specify args, you can alternatively pass bottom or top as kwargs, i.e.:

ylim(top=3)  # adjust the top leaving bottom unchanged
ylim(bottom=1)  # adjust the bottom leaving top unchanged

Setting limits turns autoscaling off for the y-axis.

Returns:
bottom, top

A tuple of the new y-axis limits.

Notes

Calling this function with no arguments (e.g. ylim()) is the pyplot equivalent of calling get_ylim on the current axes. Calling this function with arguments is the pyplot equivalent of calling set_ylim on the current axes. All arguments are passed though.

Examples using matplotlib.pyplot.ylim

© 2012–2018 Matplotlib Development Team. All rights reserved.
Licensed under the Matplotlib License Agreement.
https://matplotlib.org/3.1.1/api/_as_gen/matplotlib.pyplot.ylim.html