matplotlib.pyplot.ylim#

matplotlib.pyplot.ylim(*args, **kwargs)[源代码][源代码]#

获取或设置当前 Axes 的 y 轴限制。

调用签名:

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

如果你没有指定参数,你可以选择传递 bottomtop 作为关键字参数,即:

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

设置限制会关闭 y 轴的自动缩放功能。

返回:
底部, 顶部

新的 y 轴限制的元组。

注释

不带参数调用此函数(例如 ylim())相当于在当前 Axes 上调用 get_ylim。带参数调用此函数相当于在当前 Axes 上调用 set_ylim。所有参数都会被传递。

使用 matplotlib.pyplot.ylim 的示例#

帧抓取

Frame grabbing

交互功能

Interactive functions