plt绘图标题设置,标题输出为中文【转】

转自【https://www.cnblogs.com/GouQ/p/12555660.html】

plt绘图标题设置 

 
复制代码
 1 import matplotlib.pyplot as plt
 2 
 3 plt.rcParams['font.family'] = 'SimHei'
 4 
 5 fig = plt.figure(facecolor = 'lightgrey')
 6 
 7 plt.subplot(2,2,1)
 8 plt.title('子标题')
 9 plt.subplot(2,2,2)
10 plt.title('子标题2', loc = 'left',color = 'b')
11 plt.subplot(2,2,3)
12 myfontdict = {'fontsize':12, 'color':'g', 'rotation':30}
13 plt.title('子标题3', fontdict = myfontdict)
14 plt.subplot(2,2,4)
15 plt.title('子标题4', color = 'white',backgroundcolor='black')
16 
17 plt.suptitle('全局标题',fontsize = 20, color = 'red',backgroundcolor='yellow')
18 plt.tight_layout(rect=(0,0,1,0.9))#使子图标题和全局标题与坐标轴不重叠
19 
20 plt.show()
复制代码

 

 

 

 

 

 

 

 

 

 

 

转自【https://www.cnblogs.com/GouQ/p/12555660.html】
 
【以下编辑自2020-09-18】
【以下编辑自2020-10-15】
颜色对照表

 

 

图中颜色设置参考:
  https://matplotlib.org/gallery/color/named_colors.html#sphx-glr-gallery-color-named-colors-py
 
其他可参考:
  官方,https://matplotlib.org/tutorials/index.html
  https://blog.csdn.net/qq_31192383/article/details/53977822
  https://blog.csdn.net/qq_31192383/article/details/54380736
 在图中出现数学表达式参考:
  https://matplotlib.org/tutorials/text/mathtext.html
 【以下编辑自2020-10-30】
  Python-matplotlib画图(莫烦笔记)参考:
    https://zhuanlan.zhihu.com/p/33270402
【编辑自2020-11-27】
  plot线上的点点标记(markers)
  plot函数使用
posted @ 2020-08-23 13:36  牛哥是条狗  阅读(1632)  评论(0编辑  收藏  举报