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


Python matplotlib ylim用法及代碼示例

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

用法

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

獲取或設置當前軸的y-limits。

調用簽名:

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

如果您不指定 args,您也可以將 bottomtop 作為 kwargs 傳遞,即:

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

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

返回
底部,頂部

新 y 軸範圍的元組。

注意

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

相關用法


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