matplotlib.pyplot.xlim#

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

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

调用签名:

left, right = xlim()  # return the current xlim
xlim((left, right))   # set the xlim to left, right
xlim(left, right)     # set the xlim to left, right

如果你不指定参数,你可以传递 leftright 作为关键字参数,即:

xlim(right=3)  # adjust the right leaving left unchanged
xlim(left=1)  # adjust the left leaving right unchanged

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

返回:
左, 右

新的 x 轴限制的元组。

注释

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

使用 matplotlib.pyplot.xlim 的示例#

帧抓取

Frame grabbing

交互功能

Interactive functions