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]})
I would like to see the relationship between x1,x2, and y on the same plot. I love seaborn's factorplot
so I was thinking:
sns.factorplot('x1','y',hue='x2',data=df,kind='point')
Unfortunately, it seems that factorplot throws an error if there is an empty cell in pd.crosstab(df.x1,df.x2)
. In particular, the error is:
ValueError: low >= high
Not sure why factorplot
would be unable to do this -- couldn't the empty intersection of x1,x2
just not be plotted?
For now I'm using row
instead of hue
for x2
, which splits the plot into rows. Is there a workaround to get the same behavior of hue
? Is there something important that I don't understand about why this error happens?
这应该在开发版本(即0.4.dev
)中0.4.dev
,尝试使用pip install git+git://github.com/mwaskom/seaborn.git#egg=seaborn
。
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.