成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁技術(shù)文章
文章詳情頁

Python 繪制可視化折線圖

瀏覽:12日期:2022-07-16 15:07:23

1. 用 Numpy ndarray 作為數(shù)據(jù)傳入 ply

import numpy as npimport matplotlib as mplimport matplotlib.pyplot as pltnp.random.seed(1000)y = np.random.standard_normal(10)print 'y = %s'% yx = range(len(y))print 'x=%s'% xplt.plot(y)plt.show()

Python 繪制可視化折線圖

2. 操縱坐標(biāo)軸和增加網(wǎng)格及標(biāo)簽的函數(shù)

import numpy as npimport matplotlib as mplimport matplotlib.pyplot as pltnp.random.seed(1000)y = np.random.standard_normal(10)plt.plot(y.cumsum())plt.grid(True) ##增加格點(diǎn)plt.axis(’tight’) # 坐標(biāo)軸適應(yīng)數(shù)據(jù)量 axis 設(shè)置坐標(biāo)軸plt.show()

Python 繪制可視化折線圖

3. plt.xlim 和 plt.ylim 設(shè)置每個(gè)坐標(biāo)軸的最小值和最大值

#!/etc/bin/python#coding=utf-8import numpy as npimport matplotlib as mplimport matplotlib.pyplot as pltnp.random.seed(1000)y = np.random.standard_normal(20)plt.plot(y.cumsum())plt.grid(True) ##增加格點(diǎn)plt.xlim(-1,20)plt.ylim(np.min(y.cumsum())- 1, np.max(y.cumsum()) + 1)plt.show()

Python 繪制可視化折線圖

4. 添加標(biāo)題和標(biāo)簽 plt.title, plt.xlabe, plt.ylabel 離散點(diǎn), 線

#!/etc/bin/python#coding=utf-8import numpy as npimport matplotlib as mplimport matplotlib.pyplot as pltnp.random.seed(1000)y = np.random.standard_normal(20)plt.figure(figsize=(7,4)) #畫布大小plt.plot(y.cumsum(),’b’,lw = 1.5) # 藍(lán)色的線plt.plot(y.cumsum(),’ro’) #離散的點(diǎn)plt.grid(True)plt.axis(’tight’)plt.xlabel(’index’)plt.ylabel(’value’)plt.title(’A simple Plot’)plt.show()

Python 繪制可視化折線圖

以上就是Python 繪制可視化折線圖的詳細(xì)內(nèi)容,更多關(guān)于Python 繪制折線圖的資料請關(guān)注好吧啦網(wǎng)其它相關(guān)文章!

標(biāo)簽: Python 編程
相關(guān)文章: