Python 繪制可視化折線圖
1. 用 Numpy ndarray 作為數(shù)據(jù)傳入 ply
import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt np.random.seed(1000) y = np.random.standard_normal(10) print "y = %s"% y x = range(len(y)) print "x=%s"% x plt.plot(y) plt.show()
2. 操縱坐標(biāo)軸和增加網(wǎng)格及標(biāo)簽的函數(shù)
import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt np.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-8 import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt np.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-8 import numpy as np import matplotlib as mpl import matplotlib.pyplot as plt np.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)注腳本之家其它相關(guān)文章!
相關(guān)文章
python“靜態(tài)”變量、實(shí)例變量與本地變量的聲明示例
這篇文章主要給大家介紹了關(guān)于python“靜態(tài)”變量、實(shí)例變量與本地變量的聲明的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-11-11pytorch+lstm實(shí)現(xiàn)的pos示例
今天小編就為大家分享一篇pytorch+lstm實(shí)現(xiàn)的pos示例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-01-01以視頻爬取實(shí)例講解Python爬蟲神器Beautiful Soup用法
這篇文章主要以視頻爬取實(shí)例來講解Python爬蟲神器Beautiful Soup的用法,Beautiful Soup是一個(gè)為Python獲取數(shù)據(jù)而設(shè)計(jì)的包,簡(jiǎn)潔而強(qiáng)大,需要的朋友可以參考下2016-01-01Python3中的tuple函數(shù)知識(shí)點(diǎn)講解
在本篇文章里小編給大家整理了一篇關(guān)于Python3中的tuple函數(shù)知識(shí)點(diǎn)講解內(nèi)容,有興趣的朋友們可以學(xué)習(xí)參考下。2021-01-01Python實(shí)現(xiàn)搜索算法的實(shí)例代碼
這篇文章主要介紹了Python實(shí)現(xiàn)搜索算法,文中通過實(shí)例代碼給大家分享高級(jí)搜索算法的想法,分為線性搜索和插值搜索,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-01-01python使用 HTMLTestRunner.py生成測(cè)試報(bào)告
這篇文章主要介紹了python使用 HTMLTestRunner.py生成測(cè)試報(bào)告 ,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-10-10Python替換NumPy數(shù)組中大于某個(gè)值的所有元素實(shí)例
這篇文章主要介紹了Python替換NumPy數(shù)組中大于某個(gè)值的所有元素實(shí)例,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2020-06-06