我一直在学习如何在Python中使用seaborn和pairplot。这里的一切似乎都工作正常,但由于某种原因,图例不会显示相关的颜色。我无法找到解决方案,因此如果有人有任何建议,请告诉我。
x = sns.pairplot(stats2,hue='Term',palette='husl',height=15)
您可以先删除错误的图例,然后通过添加图例plt.legend()
:
import seaborn as sns; sns.set(style="ticks", color_codes=True)
import matplotlib.pyplot as plt
tips = sns.load_dataset("tips")
g = sns.pairplot(tips[['day', 'tip']], hue='day', palette='husl', height=6)
g._legend.remove()
plt.legend(title='Day')
plt.show()
PS:要更改 ylabel:g.axes[0,0].set_ylabel('distribution', size=15)
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)