[英]Place title at the bottom of the figure of an axes?
标题沿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')
因此,在增加fighh时,它会移开:
我也尝试过: axs.set_title("mytitle", fontsize=14, va='bottom', ha='center')
无需重新定位(停留在顶部)和fontdict-form,没有变化:
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})
您希望标题位于距x轴绝对坐标的指定距离处。 因此,您首先将其定位在y=0
。 然后,您可以使用一些填充以点为单位从其偏移。
ax.set_title("Hello Title", y=0, pad=-25, verticalalignment="top")
您可以在图形创建中使用constrained_layout=True
来使标题在调整大小时不被裁剪。
即使在调整图形大小后 , 如何使图例与轴之间保持恒定距离,也提出了有关将图例放置在轴下方的类似问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.