matplotlib画图样式

1.绘图颜色设置

matplotlib绘图颜色可以自己设置也可以使用内置的样式,以下分别介绍了设置颜色的用法和设置内置样式的方法。

  • 设置各种颜色的用法: 

  1. plt.figure(facecolor='mediumslateblue',edgecolor='black')  或plt.gcf().set_facecolor('green')    注:fugure中的facecolor 是背景色(边框外的)edgecolor是边框颜色
  2. plt.axes(facecolor='blue') 或 plt.gca().patch.set_facecolor('blue')   (patch.alpha(0.5)设置的是透明度)   注:axes中的facecolor是画布的背景色(边框内的)
  3. plt.rcParams['axes.facecolor']='red' 注:将matplotlib中的画布背景色(边框内)默认值改为红色
  4. plt.rcParams['savefig.facecolor']='red'  注:画图出来的图像颜色不变,将matplotlib中保存后的背景色(边框外的)默认值改为红色
  • 颜色传送门:https://blog.csdn.net/code_segment/article/details/79217700

  • 设置各种内置样式的方法:plt.style.use('_classic_test')

  1. _classic_test
  2. seaborn
  3. seaborn-whitegrid
  4. seaborn-white
  5. seaborn-ticks
  6. seaborn-talk
  7. seaborn-poster
  8. seaborn-pastel
  9. seaborn-paper
  10. seaborn-notebook
  11. seaborn-muted
  12. seaborn-bright
  13. grayscale
  14. ggplot
  15. fivethirtyeight
  16. fast
  17. dark_background
  18. classic
  19. bmh
  20. 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

你可能感兴趣的:(python)