python - seaborn 子图的图例和标题大小的排列
问题描述
我对图例的排列和字体大小有疑问。正如您在图片中看到的,图例在图表中,而不是在它旁边(它应该在右侧)。我还想更改标题和轴的字体大小。不幸的是,我只能在它们不相邻放置的情况下这样做。有谁知道这如何工作?错误可能是由于我制作子图的方式造成的吗?
非常感谢!
#Create Boxplots for beliefed ranks
f, axes = plt.subplots(1, 2)
figure_Grank = sns.boxplot(x='Treatment',y='Believed Rank within own Gender',data=df_fig, hue="sex", palette='vlag_r', ax=axes[0]).set(title="Beliefed Rank within own Gender")
plt.legend(title="Sex", bbox_to_anchor=(0.75, 1), loc=2, borderaxespad=0., fancybox=True)
figure_rank = sns.boxplot(x='Treatment',y='Believed Rank',data=df_fig[df_fig["Period"]==4], hue="sex", palette='vlag_r', ax=axes[1]).set(title="Beliefed Rank whithin own Group")
plt.legend(title="Sex", bbox_to_anchor=(1.01, 1), loc=2, borderaxespad=0., fancybox=True)
plt.subplots_adjust(left=0,
bottom=0.2,
right=2,
top=1.2,
wspace=0.2, #this is the horizontal space between the diagrams
hspace=4) #this is the vertical space between the diagrams #0.8
解决方案
推荐阅读
- python - 选择与另一个数据框中的列匹配的行
- c++ - 如何停止 AppInsights 从简单的 http 帖子中展平字符串数组
- angular - 如何在管道中注入常量数据
- azure-resource-manager - 应用服务证书出现错误“参数 KeyVault 证书的值无效”
- python - CalDAV 或如何将 iCloud (Google...) 日历与我的应用程序同步?
- css - 我的更新页面的 css 没有正确加载,但其他页面工作得很好
- php - php(Laravel)中集合/数组的排名(重复)
- pandas - 为什么日期格式在 + MonthEnd(1) 之后变得奇怪
- r - 求解二次方程的 R 函数
- html - 无法在 Spring Boot 中加载图像