将数据添加到seaborn jointplot

Ale*_*ont 5 python matplotlib seaborn

我使用以下seaborn方法获得了一个很好的KDE联合图(其中返回和波动率是浮点数列表):

data=pd.DataFrame({"return":returns,"volatility":volatilities,})
a=sns.jointplot(x="volatility", y="return", data=data, size=10)
Run Code Online (Sandbox Code Playgroud)

如何在此关节图上叠加特定点?例如,如果我想在位置(0.2,0.2)的KDE聊天中叠加一个红点

tmd*_*son 9

您可以通过以下方式在关节轴上绘图jointplot:

a=sns.jointplot(x="volatility", y="return", data=data, size=10)
a.ax_joint.plot([0.2],[0.2],'ro')
Run Code Online (Sandbox Code Playgroud)

另外,您还可以访问xy边距子图

a.ax_marg_x
a.ax_marg_y
Run Code Online (Sandbox Code Playgroud)