Python 将标题放置在轴图形的底部?
标题垂直移动Python 将标题放置在轴图形的底部?,python,python-3.x,matplotlib,Python,Python 3.x,Matplotlib,标题垂直移动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') 因此,在增加figheight的情况下,它会移开: 我也试过: axs.set_title(“mytitle”,fontsize=14,va='bottom',ha='center')
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')
因此,在增加figheight的情况下,它会移开:
我也试过:
axs.set_title(“mytitle”,fontsize=14,va='bottom',ha='center')
无需重新定位(位于顶部)和fontdict表单,无需更改:
axs.set_title('my_title',fontdict={'fontsize':20,'verticalignment':'bottom','horizontallignment':'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})
更多信息您希望标题与X轴的绝对坐标保持指定距离。因此,首先将其定位在
y=0
。然后,您可以使用一些以点为单位的填充来移动它
ax.set_title("Hello Title", y=0, pad=-25, verticalalignment="top")
您可以在地物创建中使用constrated\u layout=True
,以便在调整大小时不裁剪标题
关于将图例定位在轴下方的类似问题,已在中提出