matplotlib bar label

Solutions on MaxInterview for matplotlib bar label by the best coders in the world

showing results for - "matplotlib bar label"
Kaiden
06 Sep 2017
1import pandas as pd
2
3# dataframe using frequencies and x_labels from the OP
4df = pd.DataFrame({'Frequency': frequencies}, index=x_labels)
5
6# display(df)
7          Frequency
8108300.0          6
9110540.0         16
10112780.0         75
11115020.0        160
12117260.0        244
13
14# plot
15ax = df.plot(kind='bar', figsize=(12, 8), title='Amount Frequency',
16             xlabel='Amount ($)', ylabel='Frequency', legend=False)
17
18# annotate
19ax.bar_label(ax.containers[0], label_type='edge')
20
21# pad the spacing between the number and the edge of the figure
22ax.margins(y=0.1)
23