Alexis Eggermont
Alexis Eggermont

Reputation: 8145

Add data to a seaborn jointplot

I've got a nice KDE joint plot using the following seaborn method (where return and volatility are lists of floats):

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

How can I overlay specific dots on this joint plot? For example, if I'd like a red dot superimposed on the KDE chat at location (0.2,0.2)

Upvotes: 6

Views: 5433

Answers (1)

tmdavison
tmdavison

Reputation: 69116

You can plot on the joint axis from the jointplot like this:

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

As an aside, you can also access the x and y margin subplots with

a.ax_marg_x
a.ax_marg_y

Upvotes: 10

Related Questions