如何将 Seaborn FacetGrid 中的图例移到情节之外? [英] How to move the legend in Seaborn FacetGrid outside of the plot?
本文介绍了如何将 Seaborn FacetGrid 中的图例移到情节之外?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有以下代码:
g = sns.FacetGrid(df, row="Type", hue="Name", size=3, aspect=3)
g = g.map(sns.plt.plot, "Volume", "Index")
g.add_legend()
sns.plt.show()
结果如下图:
如何将图例移到情节之外?
How can I move the legend outside of the plot?
推荐答案
根据上面 mwaskom 的评论,这是 OS X 中的一个错误.确实切换到另一个后端解决了这个问题.
According to mwaskom's comment above, this is a bug in OS X. Indeed switching to another backend solves the issue.
例如,我把它放到我的 matplotlibrc
中:
For instance, I put this into my matplotlibrc
:
backend : TkAgg # use Tk with antigrain (agg) rendering
这篇关于如何将 Seaborn FacetGrid 中的图例移到情节之外?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文