更改图例位置seaborn factorp

2024-05-16 16:01:58 发布

您现在位置:Python中文网/ 问答频道 /正文

g = sns.factorplot(x="time", y="pulse", hue="kind", col="diet", data=exercise)

在《海伯恩》中,有没有一种方法可以在第一个子情节中而不是第二个子情节中描绘传奇?这个例子是从这里开始的:https://seaborn.pydata.org/generated/seaborn.factorplot.html?highlight=factor#seaborn.factorplot


Tags: 方法datatimecolseabornhue例子传奇
2条回答

下面的方法应该行得通。在

g = sns.factorplot(x="time", y="pulse", hue="kind",
              col="diet", data=exercise, legend=False)
g.axes[0][0].legend()

附言:

  1. How to put the legend on first subplot of seaborn.FacetGrid?

还有一种更简单的方法:

g = sns.factorplot(x="time", y="pulse", hue="kind", col="diet",
                   data=exercise, legend_out=False)

enter image description here

相关问题 更多 >