python修改y轴刻度_Python | Y轴刻度限制
python修改y軸刻度
In some cases, we need to visualize our data within some defined range rather than the whole data. For this, we generally set the y-axis scale within a limit and this ultimately helps us to visualize better. Sometimes, it acts as zooming and a very helpful technique in data visualization. Therefore, Matplotlib has a defined function for this operation matplotlib.pyplot.ylim().
在某些情況下,我們需要在一定范圍內(nèi)可視化我們的數(shù)據(jù),而不是整個(gè)數(shù)據(jù)。 為此,我們通常將y軸比例設(shè)置在限制范圍內(nèi),這最終將幫助我們更好地可視化。 有時(shí),它在數(shù)據(jù)可視化中充當(dāng)縮放和非常有用的技術(shù)。 因此,Matplotlib為此操作matplotlib.pyplot.ylim()定義了函數(shù)。
Following is an example showing a different y-axis Limit in plots using matplotlib.pyplot.
以下示例顯示了使用matplotlib.pyplot在圖中不同的y軸限制。
Syntax:
句法:
matplotlib.pyplot.ylim(lower_limit, upper_limit ) plt.show()y軸比例限制的Python代碼 (Python code for y-axis scale limit)
import numpy as np import matplotlib.pyplot as pltx = np.arange(500) y1 = np.arange(500) for i in range(500):y1[i] = 2*x[i] + np.random.randint(0,56)plt.figure() plt.plot(x,y1) plt.xlabel('Number Line') plt.ylabel('Function') plt.title('Whole Data')plt.figure() plt.plot(x,y1) plt.ylim(-1000,2000) plt.xlabel('Number Line') plt.ylabel('Function') plt.title('Limit for Y axis is Set')Output:
輸出:
Output is as figure翻譯自: https://www.includehelp.com/python/y-axis-scale-limit.aspx
python修改y軸刻度
總結(jié)
以上是生活随笔為你收集整理的python修改y轴刻度_Python | Y轴刻度限制的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: weakhashmap_Java Wea
- 下一篇: 适用于各种列表操作的Python程序