0

Please how can I add value label to catplot bar kind. I have tried this code but it is only labeling the first bar chart on the catplot print(df)

index Product Day Amount
0 Shoes 21 22548185.12
1 Shoes 22 21780828.81
2 Shoes 23 16015888.84
3 Shoes 24 18566882.59
4 Shoes 25 24856230.61
5 Shoes 26 21044074.31
6 Shoes 27 11455286.27
7 Watches 21 12828250.00
8 Watches 22 13059850.00
9 Watches 23 12719800.00
10 Watches 24 12246100.00
11 Watches 25 13249700.00
12 Watches 26 13364250.00
13 Watches 27 13712300.00
14 Shirts 21 24948218.00
15 Shirts 22 29328927.00
16 Shirts 23 25407993.00
17 Shirts 24 12524126.00
18 Shirts 25 15268733.00
19 Shirts 26 17581806.00
20 Shirts 27 21695489.00
21 Jeans 21 36604400.00
22 Jeans 22 35965600.00
23 Jeans 23 35025400.00
24 Jeans 24 33935100.00
25 Jeans 25 36303000.00
26 Jeans 26 36126100.00
27 Jeans 27 30865300.00

I tried this code but it was only labelling the first bar chart. Please how can I label all the other subcharts

g = sns.catplot(x="Day", y="Amount", col="Product", data=df, kind="bar", legend=True)
g.fig.set_size_inches(16,8)
g.fig.subplots_adjust(top=0.81,right=0.86) 

ax = g.facet_axis(0,0)
for p in ax.patches:
    ax.text(p.get_x() - 0.01, 
    p.get_height() * 1.02, 
    '{0:.1f}m'.format(p.get_height()/1000000),
    color='black', 
    rotation='horizontal', 
    size='large')

[1]: https://i.stack.imgur.com/EkuiU.png

Amos
  • 5
  • 2

0 Answers0