利用Python進行資料分析:【Matplotlib】

來源:互聯網
上載者:User

標籤:span   info   pac   介紹   import   更改   str   and   函數   

一、簡單介紹Matplotlib 
1、Matplotlib是一個強大的Python繪圖和資料視覺效果的工具包
2、安裝方法:pip install matplotlib
3、引用方法:import matplotlib.pyplot as plt
4、繪圖函數:plt.plot()
5、顯示映像:plt.show()

二、Matplotlib:plot函數 
1、plot函數:繪製折線圖
  --線型linestyle(-,-.,--,..)
  --點型marker(v,^,s,*,H,+,x,D,o,…)
  --顏色color(b,g,r,y,k,w,…)
2、plot函數繪製多條曲線
3、pandas包對plot的支援

三、Matplotlib-映像標註 
  --設定映像標題:plt.title()
  --設定x軸名稱:plt.xlabel()
  --設定y軸名稱:plt.ylabel()
  --設定x軸範圍:plt.xlim()
  --設定y軸範圍:plt.ylim()
  --設定x軸刻度:plt.xticks()
  --設定y軸刻度:plt.yticks()
  --設定曲線圖例:plt.legend()

四、Matplotlib執行個體——繪製數學函數映像 
使用Matplotlib模組在一個視窗中繪製數學函數y=x, y=x2, y=3x3+5x2+2x+1的映像,使用不同顏色的線加以區別,並使用圖例說明各個線代表什麼函數。

五、Matplotlib:畫布與子圖
畫布:figure
  --fig = plt.figure()
圖:subplot
  --ax1 = fig.add_subplot(2,2,1)
調節子圖間距:
  --subplots_adjust(left, bottom, right, top, wspace, hspace)

六、Matplotlib-支援的圖類型 

七、Matplotlib——繪製K線圖 
matplotlib.finanace子包中有許多繪製金融相關圖的函數介面。
繪製K線圖:matplotlib.finance.candlestick_ochl函數

八、範例程式碼 
使用之前首先下載:pip install Matplotlib
  ---接著引入:import matplotlib.pylot as plt
  ---繪圖函數:plt.plot()
  ---顯示函數:plt.show()

使用plt.plot?可以查看它的參數
我們通過加參數,可以更改這個圖線的形狀

利用Python進行資料分析:【Matplotlib】

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.