簡體   English   中英

在Seaborn情節中更改圖例標題大小的優雅方法?

[英]Elegant way to change legend's title size in seaborn plot?

我創建了一個筆直的配對圖,並且想要更改圖例標題的大小。 我已經做到了:

matrix = sns.pairplot(...)
lg = plt.gcf().legend(title='something')
lg.get_title().set_fontsize(30)

有沒有更優雅的方法可以做到這一點?

我知道seap使用的matplotlib沒有此處討論的相關屬性: https : //github.com/matplotlib/matplotlib/issues/8699

請注意, 從matplotlib 3.0開始 ,您將能夠通過以下方式更改圖例標題的字體大小

ax.legend(..., title_fontsize=16)

要么

plt.rcParams['title_fontsize'] = 16

直到那時,

legend = ax.legend(...)
legend.get_title().set_fontsize(16)

確實是設置圖例標題的適當方法。

更改劇情圖例的標題字體大小

plt.title('something', fontsize=16)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

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