【发布时间】:2021-02-26 23:44:32
【问题描述】:
有没有办法创建 Seaborn Jointplot,然后将其他数据添加到散点图部分,而不是分布?
下面的示例在df 上创建df 和Jointplot。然后我想将df2 仅添加到散点图上,并且仍然显示在图例中。
import pandas as pd
import seaborn as sns
d = {
'x1': [3,2,5,1,1,0],
'y1': [1,1,2,3,0,2],
'cat': ['a','a','a','b','b','b']
}
df = pd.DataFrame(d)
g = sns.jointplot(data=df, x='x1', y='y1', hue='cat')
d = {
'x2': [2,0,6,0,4,1],
'y2': [-3,-2,0,2,3,4],
'cat': ['c','c','c','c','d','d']
}
df2 = pd.DataFrame(d)
## how can I add df2 to the scatter part of g
## but not to the distribution
## and still have "c" and "d" in my scatter plot legend
【问题讨论】: