當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python matplotlib xlim用法及代碼示例

本文簡要介紹 python 語言中 matplotlib.pyplot.xlim 的用法。

用法

matplotlib.pyplot.xlim(*args, **kwargs)

獲取或設置當前坐標區的 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,則可以將 leftright 作為 kwargs 傳遞,即:

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

設置限製會關閉 x 軸的自動縮放。

返回
左右

新的 x 軸限製的元組。

注意

不帶參數調用此函數(例如 xlim() )相當於在當前軸上調用 get_xlim 的 pyplot。使用參數調用此函數相當於在當前軸上調用 set_xlim 的 pyplot。所有參數都通過了。

相關用法


注:本文由純淨天空篩選整理自skytowner.com大神的英文原創作品 matplotlib.pyplot.xlim。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。