資料分析與展示——Matplotlib基礎繪圖函數樣本,資料分析matplotlib

來源:互聯網
上載者:User

資料分析與展示——Matplotlib基礎繪圖函數樣本,資料分析matplotlib
Matplotlib庫入門Matplotlib基礎繪圖函數樣本pyplot基礎圖表函數概述

函數 說明
plt.plot(x,y,fmt, ...) 繪製一個座標圖
plt.boxplot(data,notch,position) 繪製一個箱體圖
plt.bar(left,height,width,bottom) 繪製一個橫條圖
plt.barh(width,bottom,left,height) 繪製一個橫向橫條圖
plt.polar(theta,r) 繪製極座標圖
plt.pie(data,explode) 繪製餅圖
plt.pas(x,NFFT=256,pad_to,Fs) 繪製功率譜密度圖
plt.specgram(x,NFFT=256,pad_to,F) 繪製譜圖
plt.cohere(x,y,NFFT=256,Fs) 繪製X-Y的相關性函數
plt.scatter(x,y) 繪製散佈圖,其中,x和y長度相同
plt.step(x,y,where) 繪製步階圖
plt.hist(x,bins,normed) 繪製長條圖
plt.contour(X,Y,Z,N) 繪製等值圖
plt.vlines() 繪製垂直圖
plt.stem(x,y,linefmt,markerfmt) 繪製柴火圖
plt.plot_date() 繪製資料日期
pyplot餅圖的繪製
import matplotlib.pyplot as pltlabels = 'Frogs', 'Hogs' ,'Dogs' ,'Logs'sizes = [15, 30, 45, 10]explode = (0, 0.1, 0, 0)plt.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%', shadow=False,startangle=90)plt.show()

 

import matplotlib.pyplot as pltlabels = 'Frogs', 'Hogs' ,'Dogs' ,'Logs'sizes = [15, 30, 45, 10]explode = (0, 0.1, 0, 0)plt.pie(sizes, explode=explode, labels=labels, autopct='%1.1f%%', shadow=False,startangle=90)plt.axis('equal')plt.show()

pyplot長條圖的繪製
import numpy as npimport matplotlib.pyplot as pltnp.random.seed(0)mu, sigma = 100, 20     # 均值和標準差a = np.random.normal(mu, sigma, size=100)plt.hist(a, 20, normed=1, histtype='stepfilled', facecolor='b', alpha=0.75)    # 第二個參數bin:長條圖的個數plt.title('Histogram')plt.show()

pyplot極座標的繪製
import numpy as npimport matplotlib.pyplot as pltN = 20theta = np.linspace(0.0, 2 * np.pi, N, endpoint=False)radii = 10 * np.random.rand(N)width = np.pi / 4 * np.random.rand(N)ax = plt.subplot(111, projection='polar')bars = ax.bar(theta, radii, width = width, bottom = 0.0)for r, bar in zip(radii, bars):    bar.set_facecolor(plt.cm.viridis(r / 10.))    bar.set_alpha(0.5)plt.show()

pyplot散佈圖的繪製
import numpy as npimport matplotlib.pyplot as pltfig, ax = plt.subplots()ax.plot(10 * np.random.randn(100), 10 * np.random.randn(100), 'o')ax.set_title('Simple Scatter')plt.show()

 

 

聯繫我們

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