Seaborn Pairplot图例不显示颜色

时间:2020-04-22 20:45:42

标签: python pandas seaborn

我一直在学习如何在python中使用seaborn和pairplot。这里的所有内容似乎都可以正常工作,但由于某些原因,图例将不会显示相关的颜色。我无法找到解决方案,因此如果有人有任何建议,请告诉我。

x = sns.pairplot(stats2,hue ='Term',palette ='husl',height = 15) enter image description here

2 个答案:

答案 0 :(得分:2)

您可以先删除错误的图例,然后通过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()

resulting plot

PS:要更改ylabel:g.axes[0,0].set_ylabel('distribution', size=15)

答案 1 :(得分:1)

尝试明确添加图例

SUBSTR('ORA-01427: single-row subquery returns more than one row', 12)