簡體   English   中英

將標題放在軸圖的底部?

[英]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})

有關文本cmds的更多信息

您希望標題位於距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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM