0

enter image description hereenter image description hereenter image description hereenter image description here

Hi I have two columns in a table, say 'A' and 'B'. I am trying to make a ridge plot with 'A' aggregated into 20 bins of 'B', I understand, one option is to bin the values first and then plot it, but in that case the x-axis would be that of A, but I want the x-axis of the ridge plots to be marked by 'B'-ie the bins.

Something similar to the attaches, coded in Matlab (the figure with Population in y axis and NO2 in y axis)- but I would prefer a similar plot for multiple time-slices- therefore a ridge plot.

I could make a ridge plot with a single column in the table

df = pd.read_csv('/div/users/mes/x.csv')
stab=df[df['Var1'].str.contains('CHN|IND|USA|IDN|PAK|NGA|BRA|BGD|RUS|MEX|JPN|ETH|PHL|EGY|COD')]

cat_month = CategoricalDtype(
    ['CHN', 'IND', 'USA', 'IDN', 'PAK', 'NGA',
     'BRA', 'BGD', 'RUS', 'MEX','JPN','ETH','PHL','EGY','COD']
)

stab['Var1'] = stab['Var1'].astype(cat_month)

stab.dtypes

plt.figure(dpi=380)

fig, ax = joyplot(
    data=stab[['A1','A2','A3', 'B','Var1']], 
    by='Var1',
    column=['A1','A2','A3'],
    color=[ '#282828', '#FFD700','#0000EE'],
    legend=True, 
    alpha=0.5,ylim='own',
    figsize=(11, 19)
)

# for a in ax[: -1]:
#      a.set_xlim([0,10])
ax[-1].set_xticks([ 0,2,4,6,8,10 ])
ax[-1].set_xticklabels(['0','2','4','6','8','10'],fontsize=18)
plt.xlabel('Vulnerability Index',  fontsize=18)
plt.rc("font", size=18)
ax[-1].legend(fontsize=16)

plt.title('SSP5', fontsize=20)
plt.show()
xxsou
  • 43
  • 6
  • Can you share what `stab` looks like? maybe paste the results of `stab.head(20).to_dict(orient='list')`? Also what is `joyplot`? is that a custom function? What does your plot currently look like? – mitoRibo Aug 08 '22 at 21:23
  • Thanks @mitoRibo , I have attached how my current figure looks like and the header of 'stab'. I am trying to plot A1-3 within ~x bins of B. – xxsou Aug 09 '22 at 10:50
  • @mitoRibo I guess, what I am trying is more like an area plot. BTW. here you may find more info on joypy https://pypi.org/project/joypy/ – xxsou Aug 09 '22 at 11:01

0 Answers0