Is there a way to plot the following bar into a grouped barplot that I could represent it as a single bar where it would be separated, more like overlapping.
What I thought about is using a stacked bar but the problem is I do not want the values to be summed up like here Stacked Bar Chart with Centered Labels
My data looks something like this:
customer avg_price avg_price2 p_50 p_75 p_90 count
0 A 2.84 5.7681 2.72 3.42 4.090 526181
1 B 2.73 6.3373 2.57 3.52 4.360 646022
2 C 2.51 21.4732 1.67 3.35 5.442 1140
3 D 2.19 9.3906 1.87 3.15 3.430 110729
4 E 2.19 5.6669 2.00 2.70 3.630 703413
I want to plot p_50, p_75, p_90 as columns.
So I tried to plot them by overlapping each bar starting with the largest to the lowest. The thing is these being percentiles I can't simply stacked them since they don't necessarily add to a total value.
fig, ax = plt.subplots(figsize=(15,11))
df.sort_values(by='avg_price').plot.barh(x='customer', y=['p_90'], width=0.75, ax=ax, color='darkblue');
df.sort_values(by='avg_price').plot.barh(x='customer', y=['p_75'], width=0.75, ax=ax);
df.sort_values(by='avg_price').plot.barh(x='customer', y=['p_50'], width=0.75, ax=ax, color='lightblue');
ax.bar_label(ax.containers[0], labels=[f'{p:.2f}' for p in df.sort_values(by='avg_price')['p_90']], label_type='center');
ax.bar_label(ax.containers[0], labels=[f'{p:.2f}' for p in df.sort_values(by='avg_price')['p_75']], label_type='center');
ax.bar_label(ax.containers[0], labels=[f'{p:.2f}' for p in df.sort_values(by='avg_price')['p_50']], label_type='center');
While trying to label each column with their proper the values they overlap. How can I properly label each section?