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
如果您未指定`args`,可以通过`kwargs`传入`left`或`right`,例如:
xlim(right=3) # adjust the right leaving left unchanged xlim(left=1) # adjust the left leaving right unchanged
设置限制会关闭x轴的自动缩放。
- 返回:
- left, right
新的x轴限制元组。
备注
不带参数调用此函数(例如
xlim()
)相当于在当前Axes上调用get_xlim
。带参数调用此函数相当于在当前Axes上调用set_xlim
。所有参数都会直接传递。