2

I have the following code:

import pandas as pd
import seaborn as sns


df = pd.DataFrame({'reg': ['A', 'B', 'C'],
                   'file': ['1', '1', '2'],
                   'val': [1, 2, 3]})
g = sns.FacetGrid(df, col='file', hue='reg', col_wrap=3)
g.map(sns.barplot, 'reg', 'val',  order=df.reg.unique()).add_legend()
g.savefig('test_so.png')

How can I add the numbers of val on top of the bars ?

UPDATE

This questions differs from this because that solution does not work with facetgrid

quant
  • 4,062
  • 5
  • 29
  • 70
  • 1
    The quesiton that you linked does not have any information regarding facetgrid. Please remove the duplicate – quant Jul 29 '19 at 15:48
  • Please refer to this solution: https://stackoverflow.com/questions/45849028/seaborn-facetgrid-pointplot-label-data-points. – warwick12 Jul 29 '19 at 16:15
  • This solution works for me for facetgrid. https://stackoverflow.com/a/51535326/560821. Saves me a lot of time. I agree with @quant. This is not a duplicate query – Denz Choe Jul 01 '22 at 08:57

0 Answers0