matplotlib 调整图片的 font size

IJCAI 投稿最开始,没有设置好图片的字体大小,现在被"编辑"要求调整字体大小,贼难受。

设置legend 的位置:

让 legend 的顺序倒过来

handles, tag_labels = ax[0,1].get_legend_handles_labels()
ax[0,1].legend(handles[::-1], tag_labels[::-1], loc='upper right', bbox_to_anchor=(0.42, 1.08), fontsize=11)
设置 x/y axis 刻度字体的大小:
 ax[x,y].set_xlim(0, 0.25)
  ax[x,y].set_xticks([0,0.05,0.1,0.15,0.2])  # 不可少此,否则下面的命令导致的结果不对。
  ax[x,y].set_xticklabels([0,0.05, 0.1, 0.15, 0.2], fontsize=16)
调整图片纵横比例,使得其能够充满半行,或者一行。
fig, ax = plt.subplots(2,2, figsize=[7, 6]) #sharex='all'
fig, ax = plt.subplots(1, 3, sharex='all', figsize=[7*3*0.6, 6.4*0.6*0.8])
fig, ax = plt.subplots(2, 2, figsize=[6.4*2*0.6, 6.4*0.6])
fig, ax = plt.subplots(2, 3, figsize=[7*3*0.6, 6.4*0.6*0.8])
fig, ax = plt.subplots(1, 3, sharey='all', sharex='all')
原文地址:https://www.cnblogs.com/Gelthin2017/p/14773325.html