【问题标题】:Changing axis label size in Seaborn catplot在 Seaborn catplot 中更改轴标签大小
【发布时间】:2021-07-20 03:00:03
【问题描述】:

我正在尝试放大 x 轴标签(即“陆上”、“离岸”和“太阳能”),同时旋转它们。但是每当我增加大小时,我的 cat 子图的列大小就会减小并压缩图像。有没有办法在不减少/压缩 seaborn catplot 中的子图的情况下增加轴标签的字体大小?

这是我的代码:

#plt.subplots(figsize=(28,12))
sns.set_theme(style = "whitegrid", font_scale= 1.9)
ax = sns.catplot(x="generator", y="ELCC", hue="Nameplate Capacity",
            col="Scenario", aspect=.7,
            kind="box",palette = 'RdYlBu', data=final_df)
plt.legend(bbox_to_anchor = (1, 1))
ax.set_xticklabels(rotation = 30)
ax.set_xlabels('Generator Type', fontsize=20) # not set_label
ax.set_ylabels('ELCC', fontsize= 20)
ax.fig.set_size_inches(45,22)
plt.show()

【问题讨论】:

  • sns.set_theme(style = "whitegrid", font_scale= 1.9)如果我不需要这条线会怎样?为什么没有启用字体调整大小?
  • 该行用于放大子图字体大小,例如图上方的文本以及'solar'、'onshore、'offshore'

标签: matplotlib seaborn axis-labels facet-grid catplot


【解决方案1】:

对于那些面临同样问题的人 - 我找到了解决方法,可以使用 Seaborn 中猫图的“高度”和“纵横比”参数。每个面或每个子图的宽度等于高度*纵横比。 这个stackoverflow post 很有帮助。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-09-25
    • 2015-02-10
    • 2019-11-10
    • 1970-01-01
    • 2011-07-18
    • 2022-09-28
    • 1970-01-01
    相关资源
    最近更新 更多