資料視覺化matplotlib的應用(二)

2021-07-25 18:02:29 字數 1971 閱讀 4685

對邊框和horizontal 一些設定:

ax1.spines['left'].set_color('c')     #將左邊框欄設定c顏色

ax1.spines['right'].set_visible(false)   #將右邊框欄設定不可見

ax1.spines['top'].set_visible(false)    #將上邊框欄設定為不可見

ax1.spines['left'].set_linewidth(5)    #將左邊框欄的寬度設定為5

ax1.tick_params(axis='x', colors='#f06215')  #將x軸的標籤顏色設定成#f06215

ax1.axhline(closep[0], color='k', linewidth=5)   #將horizontal 就是橫軸顏色設定k,寬度設定為5

ohlc和candlestick的應用:

用style訂製matplotlib

from matplotlib import style

style.use('ggplot')

style.use('fivethirtyeight')

ax1.plot(date,closep)

ax1.plot(date,openp)

#還可以使用的sytle如下:

animation的使用:

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...