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为子图间距
(可以先使用导航工具栏进行调试,将数据填入即可)