簡體   English   中英

如何更改matplotlib中的軸限制?

[英]How to change the limits of axes in matplotlib?

我有x軸從0-100開始的圖。 我想將其更改為10-100。 如果有人可以提出任何建議,我將不勝感激。 謝謝

如果僅將pyplot用於簡單繪圖,則可以嘗試以下功能

import matplotlib.pyplot as plt
...
plt.xlim(10, 100)

如果要設置特定的axes ,可以嘗試以下方法

import matplotlib.pyplot as plt
...
ax = plt.gca()
ax.set_xlim(10, 100)

此處的SO社區Wiki

set_xlim()限制在繪圖上顯示的數據。

為了更改軸的邊界,請使用set_xbound()

所以我很確定你真的想要

ax.set_xbound(lower=10, upper=100)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM