1

I want to create ridgelines plots for the distribution of property Rg as it changes with temperature. It turns out that I have an attribute Z that changes too, so I want the distribution of Rg at a given condition, for both attributes Z1 and Z2. I want the ridgeline plots to be side by side. This is what I have so far:

import pandas as pd
import numpy as np 
import matplotlib.pyplot as plt 
import joypy as j
from joypy import joyplot 
import seaborn as sns

df_iso = pd.DataFrame(data=d_iso)
df_atac = pd.DataFrame(data=d_atac)

plt.figure() 
joyplot(data=df_iso[['temperature', 'Rg']], by='temperature', column='Rg', figsize=(12, 8))
joyplot(data=df_atac[['temperature', 'Rg']], by='temperature', column='Rg', figsize=(12, 8))
plt.title('Ridgeline plot of Rg histograms')
plt.show()

My plots look like this: enter image description here

I want them to be on the same plot, with different colors and legends for each color.

How can I go about this? Any advice you have would be appreciated.

bad_chemist
  • 283
  • 1
  • 7
  • `joypy` doesn't support drawing more than one joyplot in the same figure. As a matter of fact, at each call it creates its own figure. Your call to `plt.figure()` has no effect apart from creating a dummy empty figure. – JohanC Nov 02 '21 at 07:01

1 Answers1

0

You shall merge the two dataframes by merge. And include another column to plot. That would be work

df_iso = pd.DataFrame(data=d_iso)
df_atac = pd.DataFrame(data=d_atac)
dfMerge = pd.merge(df_iso[['temperature']], df_atac[['temperature']], right_on='temperature')
plt.figure() 
joyplot(data=dfMerge[['temperature', 'Rg']], by='temperature', column='Rg', figsize=(12, 8))
plt.title('Ridgeline plot of Rg histograms')
plt.show()
Pawel Kam
  • 1,684
  • 3
  • 14
  • 30