标题垂直移动y
,但是如果figheight更改,标题与X轴的距离/填充不是恒定的:
fig, axs = plt.subplots(1,1, figsize=(15,2.5*1.5))
axs.set_title("mytitle", fontsize=14, y=-0.2, ha='center')
所以当它移走的时候
我也试过:
axs.set_title("mytitle", fontsize=14, va='bottom', ha='center')
无需重新定位(停留在顶部)和fontdict表单,无需更改:
axs.set_title('my_title', fontdict={'fontsize': 20, 'verticalalignment': 'bottom', 'horizontalalignment': 'center'})
编辑
标题只是我现在使用的文本,其模块化:
axs.text(0.5,1,'some_title', va='bottom', ha='center', transform=axs.transAxes, color='k', fontsize=15, bbox={'facecolor':'white', 'edgecolor':'white', 'alpha':1, 'pad':10})
更多信息请访问text cmds.
您希望标题与xaxis保持指定的绝对坐标距离。因此,首先将其定位在
y=0
。然后你可以使用一些以点为单位的填充来移动它。你知道吗您可以在图形创建中使用
constrained_layout=True
,以便在调整大小时不裁剪标题。你知道吗在How to get constant distance between legend and axes even when the figure is resized?中提出了一个类似的关于将图例放置在轴下方的问题
相关问题 更多 >
编程相关推荐