Matplotlib資料視覺化筆記

2021-10-05 12:53:04 字數 4643 閱讀 8015

等高線圖,彩色圖,兩者結合版

二維頻次直方圖

折線圖,散點圖,直方圖,這三種可以畫的千奇百怪,下面就簡單介紹其中幾種精美的圖形
fig=plt.figure(

)ax=plt.axes(

)x=np.linspace(-10

,10,2000

)plt.plot(x, np.sin(x -0)

, color=

'blue'

)# 標準顏色名稱

plt.plot(x, np.sin(x -1)

, color=

'g')

# 縮寫顏色**(rgbcmyk)

plt.plot(x, np.sin(x -2)

, color=

'0.75'

)# 範圍在0~1的灰度值

plt.plot(x, np.sin(x -3)

, color=

'#ffdd44'

)# 十六進製制(rrggbb,00~ff)

plt.plot(x, np.sin(x -4)

, color=

(1.0

,0.2

,0.3))

# rgb元組,範圍在0~1

plt.plot(x, np.sin(x -5)

, color=

'chartreuse');

# html顏色名稱

# 實線

plt.plot(x, x +

5, linestyle=

'--'

)# 虛線

plt.plot(x, x +

6, linestyle=

'-.'

)# 點劃線

plt.plot(x, x +

7, linestyle=

':')

;# 實點線

# 顯示顏色條

這裡以鳶尾花資料進行介紹散點圖,說不定能夠加深大家對機器學習的理解,看著這張圖不知道大家想起了什麼?

)#rdgy就是red-gray的乙個顏色對,等高線

plt.contourf(x,y,z,

20,camp=

'rdgy'

)#彩色圖

)#仔細觀察可以發現就是contour,clabel和imshow三者結合版

)#顏色條

cb.set_label(

'counts in bin'

)#plt.hexbin(x, y, gridsize=30, cmap='blues') #六邊形

顏色越深表示頻率越高

相關系列matplotlib資料視覺化筆記正在逐步更新中…

Matplotlib 資料視覺化

資料視覺化,更有意義的說法是,data communication for audiences。matplotlib總是因為它的aesthetics和amounts of codes被些許詬病。然而,我覺得熟練的使用之後,它的靈活性還是比較強的 相比ggplot 所以這篇文章的適合讀者是 具體的實現...

資料視覺化 matplotlib

直方圖plt.hist 資料,分組數,density true 複製 條形圖plt.bar x,y,color 顏色 plt.barh 複製 散點圖plt.scatter x,y 複製 折線圖 繪製多個圖形,多次plot plt.plot x,y,label 標籤 複製 通用操作plt.figure...

matplotlib視覺化excel資料

matploylib是python的一基礎視覺化工具,可以用於處理大量資料或載入api完成視覺化。比如處理excle資料,如下 import openpyxl import matplotlib.pyplot as plt import numpy as np filename g40.xlsx i...