I'm using a kdeplot to plot the densities of two bivariate distributions like this, where df_c
and df_n
are two Pandas DataFrames:
f, ax = plt.subplots(figsize=(6, 6))
sns.kdeplot(df_c['attr1'], df_c['attr2'], ax=ax, cmap='Blues', shade_lowest=False)
sns.kdeplot(df_n['attr1'], df_n['attr2'], ax=ax, cmap='Reds', shade_lowest=False)
I would like to also include marginal histograms like those generated by jointplot (example plot). However, I cannot use jointplot (because it is appearantly not possible to plot two different distributions with jointplot, as it will generate a new Figure every time it is called), and I cannot find any information on how to reproduce the marginal histograms it produces.
Is there an easy way to produce a kdeplot with marginal histograms using Seaborn / matplotlib? Alternatively, did I overlook a way to plot two separate distributions using a jointplot?
You can use
seaborn.JointGrid
. The key, as explained by seaborn's author in this Github issue, is to useHopefully the following example is what you want: