我如何在绘制点的旁边用col1“ A”“ B”或“ C”的值作为文本注释海洋点图。
import pandas as pd
import numpy as np
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 value
0 A D 3
1 B E 1
2 C D -3
3 A E -5
4 B D -4
5 C E -5
6 A D 2
7 B E -4
8 C D 4
9 A E 1
10 B D 3
11 C E -2
sns.pointplot(data=df, x="col2", y="value", hue='col1');
所需的结果带有标签A,B和C: