我有一个具有以下属性的数据框:
import numpy as np
import pandas as pd
import seaborn as sns
df = pd.DataFrame({'att1': np.random.choice([1, 3, 5, 8, 10, 30, 50, 100], 500),
'att2': np.random.choice(['a', 'b', 'c', 'd', 'e', 'f', 'g'], 500),
'att3': np.random.choice(['t1', 't2', 't3', 't4'], 500),
'type': np.random.choice(['positive', 'negative'], 500),
'value': np.random.normal(0, 20, 500)})
我想绘制att3与值的箱线图,并能够按正负类型彼此相邻的att2(以不同颜色显示)分组。 att2为正-负,并且必须彼此相邻显示 目前,我只能按att2分组,而不能将不同类型的att2放在一起。 我正在使用seaborn boxplots完成此操作
ax = sns.boxplot(x="att3", hue="att2", y="value", data=df)
我得到这样的东西:
有人可以告诉我我们如何实现这一目标吗?预先感谢