Kos*_*kis 1 python matplotlib seaborn
我创建了一个 seaborn pairplot,我想更改图例标题的大小。我已经这样做了:
matrix = sns.pairplot(...)
lg = plt.gcf().legend(title='something')
lg.get_title().set_fontsize(30)
Run Code Online (Sandbox Code Playgroud)
有没有更优雅的方法来做到这一点?
我知道由 seaborn 使用的 matplotlib 没有此处讨论的相关属性:https : //github.com/matplotlib/matplotlib/issues/8699
请注意,从 matplotlib 3.0 开始,您将能够通过以下方式更改图例标题字体大小
ax.legend(..., title_fontsize=16)
Run Code Online (Sandbox Code Playgroud)
或者
plt.rcParams['title_fontsize'] = 16
Run Code Online (Sandbox Code Playgroud)
直到那时,
legend = ax.legend(...)
legend.get_title().set_fontsize(16)
Run Code Online (Sandbox Code Playgroud)
确实是设置图例标题的适当方法。
| 归档时间: |
|
| 查看次数: |
7021 次 |
| 最近记录: |