matplotlib - 在 Seaborn catplot 中更改轴标签大小
问题描述
我正在尝试放大 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()
解决方案
对于那些面临同样问题的人 - 我找到了一个解决方法,可以在 Seaborn 中使用 catplot 的“高度”和“纵横比”参数。每个面或每个子图的宽度等于高度*纵横比。这个stackoverflow 帖子很有帮助。
推荐阅读
- c# - 通过实体框架中的表名检索表列
- node.js - AWS 使用 JavascriptServices(AspnetCore.NodeServices) 部署 Asp.net-Core 应用程序
- string - 如何用 Fish 计算符号而不是字符串长度?
- perl - 通过 SOAP 访问特定的 OTRS 动态字段值
- caching - Does redis itself have cache?
- swift - 隐藏字段未以 Eureka swift 形式提交其值
- javascript - Deleting multiple child components from parent component in react
- networking - Kubernetes services cannot reach each other anymore
- html - Justified Gallery issue
- python - 如何在for循环中遍历熊猫行