python - 删除 Seaborn 条形图图例标题

标签 python matplotlib bar-chart seaborn

我使用 seaborn 绘制分组条形图,如 https://seaborn.pydata.org/examples/factorplot_bars.html 所示

给我: https://seaborn.pydata.org/_images/factorplot_bars.png

我想删除图例上的标题(性别)。

我怎样才能做到这一点?

最佳答案

这可能是一个 hacky 解决方案,但它有效:如果您告诉 Seaborn 在绘图时将其关闭,然后将其添加回去,它没有图例标题:

g = sns.factorplot(x='Age Group',y='ED',hue='Became Member',col='Coverage Type',
                   col_wrap=3,data=gdf,kind='bar',ci=None,legend=False,palette='muted')
#                                                         ^^^^^^^^^^^^
plt.suptitle('ED Visit Rate per 1,000 Members per Year',size=16)
plt.legend(loc='best')
plt.subplots_adjust(top=.925)
plt.show()

示例结果:

enter image description here

关于python - 删除 Seaborn 条形图图例标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43151440/

相关文章:

python - Pygame:如何多态地编写事件循环

python - Python 的 MYSQL 错误

python - 如何从python中的随机分布中找到指数曲线(和曲线)下的面积?

python - 不能根据数据在现有图上绘制计算的质心值

python - 将 matplotlib 文本与颜色条对齐

r - 用 R 分组的条形图

python - python 中的 urllib.quote 点字符 (.)

python - 使用 to_pickle 在循环中保存多个数据帧

python - 我在 matplotlib (python) 中有一个带有误差线的条形图,但我想要误差线在中间。我该怎么做呢?谢谢

javascript - 如何删除条形图中的填充? (图表.JS)