注释FacetGrid点图

问题描述

我如何在col1的值“ A”或“ B”的文本旁边,在“ E”上绘制的点旁边注释一个认的FacetGrid点图。

import pandas as pd
import matplotlib.pyplot as plt
import seaborn as sns

# Data
a = list("ABC") * 4
c = list("DE") * 6
score = np.random.randint(-5,5,12)
df = pd.DataFrame({"col1": a,"col2": c,"score": score})
print(df)

   col1 col2  score
0     A    D      4
1     B    E      2
2     C    D     -2
3     A    E     -3
4     B    D      4
5     C    E     -3
6     A    D      2
7     B    E      2
8     C    D     -5
9     A    E      1
10    B    D     -1
11    C    E     -3

g = sns.FacetGrid(data=df,hue="col1",height=5)
g.map(sns.pointplot,"col2","score",**dict(order=["D","E"]));

enter image description here

所需的结果带有标签A,B和C:

enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)