Python 繪制可視化折線圖
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()
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()
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()
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 繪制可視化折線圖的詳細(xì)內(nèi)容,更多關(guān)于Python 繪制折線圖的資料請(qǐng)關(guān)注好吧啦網(wǎng)其它相關(guān)文章!
相關(guān)文章:
1. ASP動(dòng)態(tài)網(wǎng)頁制作技術(shù)經(jīng)驗(yàn)分享2. 詳解瀏覽器的緩存機(jī)制3. vue3+ts+elementPLus實(shí)現(xiàn)v-preview指令4. jsp文件下載功能實(shí)現(xiàn)代碼5. 如何在jsp界面中插入圖片6. Xml簡(jiǎn)介_動(dòng)力節(jié)點(diǎn)Java學(xué)院整理7. .Net Core和RabbitMQ限制循環(huán)消費(fèi)的方法8. phpstudy apache開啟ssi使用詳解9. jsp實(shí)現(xiàn)登錄驗(yàn)證的過濾器10. JSP之表單提交get和post的區(qū)別詳解及實(shí)例
