文章目录
绘制基本流程:
(1)创建画布
(2)准备x y数据
(3)进行绘制图形
(4)进行图形展示
(1)调整子图与子图之间的间距
#调整图与图之间的间距
#hspace 调整高度
#wspace 调整宽度
plt.subplots_adjust(hspace=0.8, wspace=0.5)
位置:放在开头创建画布后面即可
参数:0.8,0.5 根据需要调
(2)设置RC参数支持中文和负号
#默认不支持中文,想用中文,必须用RC参数
plt.rcParams['font.sans-serif'] = 'SimHei' # 设置RC字体 让其支持中文
#默认不支持负号,想要支持负号,必须设置RC参数
plt.rcParams['axes.unicode_minus'] = False # 设置RC编码 ,让其支持负数
位置:放在开头创建画布后面即可
(3)增加子图
例如:
#增加子图1
fig.add_subplot(2, 2, 1)
# 增加子图2
fig.add_subplot(2, 2, 2)
# 增加子图3
fig.add_subplot(2, 2, 3)
# 增加子图4
fig.add_subplot(2, 2, 4)
位置