我正在使用Seaborn绘制两个子图,代码如下:
fig, (ax1, ax2) = plt.subplots(ncols=2, sharey=True)
sns.swarmplot(flowers[0], flowers[1], hue=colours, ax=ax1)
ax1.set(xlabel='Sepal Length', ylabel='Sepal Width')
plt.legend(loc="upper left", bbox_to_anchor=(1, 1))
sns.swarmplot(flowers[2], flowers[3], hue=colours, ax=ax2)
ax2.set(xlabel='Petal Length', ylabel='Petal Width')
sns.plt.show()
然而,每个子图都有由颜色决定的自己的图例。是否可以删除其中一个,并最好将剩余的放在图外?我尝试使用 ax1.legend_.remove()
,但没有成功。
factorplot
。 - mwaskom