1.繪圖顏色設置
matplotlib繪圖顏色可以自己設置也可以使用內置的樣式,以下分別介紹了設置顏色的用法和設置內置樣式的方法。
-
設置各種顏色的用法:
- plt.figure(facecolor='mediumslateblue',edgecolor='black') 或plt.gcf().set_facecolor('green') 注:fugure中的facecolor 是背景色(邊框外的)edgecolor是邊框顏色
- plt.axes(facecolor='blue') 或 plt.gca().patch.set_facecolor('blue') (patch.alpha(0.5)設置的是透明度) 注:axes中的facecolor是畫布的背景色(邊框內的)
- plt.rcParams['axes.facecolor']='red' 注:將matplotlib中的畫布背景色(邊框內)默認值改爲紅色
- plt.rcParams['savefig.facecolor']='red' 注:畫圖出來的圖像顏色不變,將matplotlib中保存後的背景色(邊框外的)默認值改爲紅色
-
顏色傳送門:https://blog.csdn.net/code_segment/article/details/79217700
-
設置各種內置樣式的方法:plt.style.use('_classic_test')
- _classic_test
- seaborn
- seaborn-whitegrid
- seaborn-white
- seaborn-ticks
- seaborn-talk
- seaborn-poster
- seaborn-pastel
- seaborn-paper
- seaborn-notebook
- seaborn-muted
- seaborn-bright
- grayscale
- ggplot
- fivethirtyeight
- fast
- dark_background
- classic
- bmh
- Solarize-Light2和tableau-colorblind10報錯了,不知道怎麼用
2.多子圖設置
-
多子圖標題設置
plt.suptitle("多個子圖的總體標題",fontsize=字號)
-
設置子圖的間距和整圖邊距空白
plt.subplots_adjust(left=0.1,bottom=0.11,right=0.91,top=0.9,wspace=0.2,hspace=0.5)
其中參數可設置:left、bottom、right、left爲整圖邊距空白,wspace和hspace爲子圖間距
(可以先使用導航工具欄進行調試,將數據填入即可)
參考資料:https://blog.csdn.net/helunqu2017/article/details/78650339