Python3繪圖之Matplotlib(01)

來源:互聯網
上載者:User

標籤:知識   body   成就   range   otl   ott   小結   ring   info   

1 First plots with Matplotlib簡單的繪圖1簡單的繪圖2簡單的繪圖32 網格 = grid3 設定座標軸的取值範圍 = axis xlim ylim方法1:整體設定[xmin, xmax, ymin, ymax]   ===》plt.axis([xmin, xmax, ymin, ymax])方法2:分別設定plt.xlim([xmin, xmax])plt.ylim([ymin, ymax])4 設定座標含義標籤 = label5 設定圖片的整體標題 = title6 設定圖例 = legend方法2:plt.plot(x, x*1.5)plt.plot(x, x*3.0)plt.plot(x, x/3.0)plt.legend([‘Normal‘, ‘Fast‘, ‘Slow‘])圖例的位置參數:loc = Code
String Code
best 0
upper right 1
upper left 2
lower left 3
lower right 4
right 5
center left 6
center right 7
lower center 8
upper center 9
center 10
7 一副完整的映像8 儲存圖片 = savefig
import matplotlib.pyplot as pltplt.plot([1, 2, 3])plt.savefig("plot123.png")plt.savefig(‘plot123_2.png‘, dpi=200)#import matplotlib as mplmpl.rcParams[‘figure.figsize‘]mpl.rcParams[‘savefig.dpi‘]mpl.reParams[‘Agg‘]
9 本小結所有程式碼範例
import matplotlib.pyplot as pltplt.plot([1, 3, 2, 4])plt.show()import matplotlib.pyplot as pltx = range(6)plt.plot(x, [xi**2 for xi in x])plt.show()import matplotlib.pyplot as pltimport numpy as npx = np.arange(0.0, 6.0, 0.01)plt.plot(x, [x**2 for x in x])plt.show()import matplotlib.pyplot as pltimport numpy as npx = np.arange(1, 5)plt.plot(x, x*1.5, x, x*3.0, x, x/3.0)plt.grid(True)plt.show()import matplotlib.pyplot as pltimport numpy as npx = np.arange(1, 5)plt.plot(x, x*1.5, x, x*3.0, x, x/3.0)plt.axis() # 顯示當前座標軸的極限取值範圍 x->(0.85, 4.15), y->(-0.25, 12.58)plt.axis([0, 5, -1, 13]) # 從新設定當前座標軸的範圍 plt.show()import matplotlib.pyplot as pltplt.plot([1, 3, 2, 4])plt.xlabel(‘This is the X axis‘) #這個是x軸的標籤plt.ylabel(‘This is the Y axis‘) #這個是y軸的標籤plt.show()import matplotlib.pyplot as pltplt.plot([1, 3, 2, 4])plt.title(‘Simple plot‘) # 映像的標題plt.show()import matplotlib.pyplot as pltimport numpy as npx = np.arange(1, 5)plt.plot(x, x*1.5, label="Normal")plt.plot(x, x*3.0, label="Fast")plt.plot(x, x/3.0, label="Slow")plt.legend() # 設定圖例plt.show()import matplotlib.pyplot as pltimport numpy as npx = np.arange(1, 5)plt.plot(x, x*1.5, x, x*3.0, x, x/3.0)plt.grid(True)plt.title(‘Sample Growth of a Measure‘)plt.xlabel(‘Samples‘)plt.ylabel(‘Values Measured‘)plt.legend([‘Normal‘, ‘Fast‘, ‘Slow‘], loc = ‘upper left‘)plt.show()import matplotlib.pyplot as pltplt.plot([1, 2, 3])plt.savefig("plot123.png")import matplotlib as mplmpl.rcParams[‘figure.figsize‘]mpl.rcParams[‘savefig.dpi‘]plt.savefig(‘plot123_2.png‘, dpi=200)

 

知識在於點點滴滴的積累,我會在這個路上Go ahead,

有幸看到我部落格的朋友們,若能學到知識,請多多關注以及討論,讓我們共同進步,揚帆起航。後記:打油詩一首

適度鍛煉,量化指標

考量天氣,設定目標

科學鍛煉,成就體標

高效科研,實現學標

 

 

    

Python3繪圖之Matplotlib(01)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.