I’m plotting some data using sns.jointplot
and I want the data inside the scatterplot to remain as points and the histograms on the side to be kde plots instead. I’ve tried using the kind='kde'
argument, but this changes the data inside to not look like points in a scatterplot anymore. I’ve searched around for a bit and can’t find how.
Here’s my code for the plot:
JavaScript
x
10
10
1
plota = sns.jointplot( data = Hub_all_data, y = "Within module degree", x= "Participation coefficient", s=100, joint_kws=({'color':'green'}), marginal_kws=({'color': 'green'}))
2
3
plota.ax_joint.axvline(x=np.quantile(Pall,.25), color = "black", linestyle = "--")
4
plota.ax_joint.axvline(x=np.quantile(Pall,.75), color = "black", linestyle = "--")
5
plota.ax_joint.axhline(y=np.quantile(within_module_degree,.25), color = "black", linestyle = "--")
6
plota.ax_joint.axhline(y=np.quantile(within_module_degree,.75), color = "black", linestyle = "--")
7
plota.ax_marg_x.set_xlim(0, .6)
8
plota.ax_marg_y.set_ylim(-3, 2)
9
plota.set_axis_labels('P', 'Z', fontsize=16)
10
Advertisement
Answer
You could create a JointGrid
and then plot the central and the marginal plots separately:
JavaScript
1
15
15
1
import seaborn as sns
2
import numpy as np
3
4
iris = sns.load_dataset('iris')
5
g = sns.JointGrid(data=iris, x="sepal_length", y="petal_length")
6
g.plot_joint(sns.scatterplot, s=100, color='green')
7
g.plot_marginals(sns.kdeplot, color='green', fill=True)
8
9
for q in np.quantile(iris['sepal_length'], [0.25, 0.75]):
10
for ax in (g.ax_joint, g.ax_marg_x):
11
ax.axvline(q, color="black", linestyle="--")
12
for q in np.quantile(iris['petal_length'], [0.25, 0.75]):
13
for ax in (g.ax_joint, g.ax_marg_y):
14
ax.axhline(q, color="black", linestyle="--")
15