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().
在某些情況下,我們需要在一定范圍內可視化我們的數據,而不是整個數據。 為此,我們通常將y軸比例設置在限制范圍內,這最終將幫助我們更好地可視化。 有時,它在數據可視化中充當縮放和非常有用的技術。 因此,Matplotlib為此操作matplotlib.pyplot.ylim()定義了函數。
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軸刻度
總結
以上是生活随笔為你收集整理的python修改y轴刻度_Python | Y轴刻度限制的全部內容,希望文章能夠幫你解決所遇到的問題。
 
                            
                        - 上一篇: weakhashmap_Java Wea
- 下一篇: scala 字符串函数_Scala中的字
