Home > OS >  Align the values on the bar in matplotlib barplot
Align the values on the bar in matplotlib barplot

Time:08-27

I am trying to obtain a bar chart displaying value_counts() for each year.

I use the following code:

import matplotlib.pyplot as plt

df.Year.value_counts(sort=False).sort_index().plot(kind='barh')

for index, value in enumerate(df['Year'].value_counts()):
    plt.text(value, index,
         str(value))

plt.show()

The chart that I obtain is as follows:

enter image description here

  • Related