You are reading documentation for the unreleased version of Matplotlib. Try searching for the released version of this page instead?
Applications are open for the 2018 John Hunter Matplotlib Summer Fellowship. Apply now!
Version 2.2.2.post1768+g23420a4c1
matplotlib
Fork me on GitHub

Table Of Contents

matplotlib.axes.Axes.set_ylim

Axes.set_ylim(bottom=None, top=None, emit=True, auto=False, *, ymin=None, ymax=None)

Set the data limits for the y-axis

Parameters:
bottom : scalar, optional

The bottom ylim (default: None, which leaves the bottom limit unchanged). The bottom and top ylims may be passed as the tuple (bottom, top) as the first positional argument (or as the bottom keyword argument).

top : scalar, optional

The top ylim (default: None, which leaves the top limit unchanged).

emit : bool, optional

Whether to notify observers of limit change (default: True).

auto : bool or None, optional

Whether to turn on autoscaling of the y-axis. True turns on, False turns off (default action), None leaves unchanged.

ymin, ymax : scalar, optional

These arguments are deprecated and will be removed in a future version. They are equivalent to bottom and top respectively, and it is an error to pass both xmin and bottom or xmax and top.

Returns:
ylimits : tuple

Returns the new y-axis limits as (bottom, top).

Notes

The bottom value may be greater than the top value, in which case the y-axis values will decrease from bottom to top.

Examples

>>> set_ylim(bottom, top)
>>> set_ylim((bottom, top))
>>> bottom, top = set_ylim(bottom, top)

One limit may be left unchanged.

>>> set_ylim(top=top_lim)

Limits may be passed in reverse order to flip the direction of the y-axis. For example, suppose y represents depth of the ocean in m. The y-axis limits might be set like the following so 5000 m depth is at the bottom of the plot and the surface, 0 m, is at the top.

>>> set_ylim(5000, 0)

Examples using matplotlib.axes.Axes.set_ylim