import pandas as pd
import seaborn as sns
df = pd.DataFrame({'x1': ['a','a','a','b'],
'x2': ['c','d','c','d'],
'y': [3,8,15,25]})
我想在同一张图上查看 x1、x2 和 y 之间的关系。我喜欢 seaborn 的 factorplot
所以我在想:
sns.factorplot('x1','y',hue='x2',data=df,kind='point')
不幸的是,如果 pd.crosstab(df.x1,df.x2)
中有空单元格,factorplot 似乎会抛出错误。具体来说,错误是:
ValueError: low >= high
不确定为什么 factorplot
无法执行此操作 - 不能绘制 x1,x2
的空交集吗?
现在,我使用 row
而不是 hue
来表示 x2
,它将绘图分成多行。是否有解决方法来获得 hue
的相同行为?有什么重要的事情我不明白为什么会发生这个错误吗?
最佳答案
这应该在开发版本中得到修复(即 0.4.dev
),尝试使用 pip install git+git://github.com/mwaskom/seaborn.git# 安装它egg=seaborn
.
关于python - Seaborn factor plot hue 要求不为空 "cells",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25294297/