Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 将标题放置在轴图形的底部?_Python_Python 3.x_Matplotlib - Fatal编程技术网

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
,以便在调整大小时不裁剪标题

关于将图例定位在轴下方的类似问题,已在中提出