Annotate bars with values on Pandas bar plots in Python

MatplotlibServer Side ProgrammingProgramming

In this program, we can create a data frame and can plot a bar using'lab', y='value', color='#5fba34') plot.


  • Using Panda’s dataframe, we can create a data frame with the given dictionary, where the keys are lab and value, values of these keys are lists, respectively.

  • Using Pandas method, we can create a vertical bar plot. A bar plot is a plot that presents categorical data with rectangular bars with lengths proportional to the values that they represent.

  • To show the figure, use the method.


import pandas as pd

from matplotlib import pyplot as plt
df = pd.DataFrame({'lab': ['A', 'B', 'C'], 'value': [10, 30, 20]})
ax ='lab', y='value', color='#5fba34')


Published on 15-Mar-2021 08:38:55