简体   繁体   English

Seaborn因子图色调不需要空的“细胞”

[英]Seaborn factor plot hue requires no empty “cells”

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. 我想在同一个图上看到x1,x2和y之间的关系。 I love seaborn's factorplot so I was thinking: 我喜欢seaborn的factorplot所以我在想:

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) . 不幸的是,如果pd.crosstab中存在空单元格pd.crosstab(df.x1,df.x2) ,似乎factorplot会抛出错误。 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? 不确定为什么factorplot无法做到这一点 - 不能没有绘制x1,x2的空交集?

For now I'm using row instead of hue for x2 , which splits the plot into rows. 现在我正在使用row代替hue for x2 ,它将绘图分成行。 Is there a workaround to get the same behavior of hue ? 是否有解决方法来获得相同的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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM