- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Annotate bars with values on Pandas bar plots in Python
In this program, we can create a data frame and can plot a bar using df.plot.bar(x='lab', y='value', color='#5fba34') plot.
Steps
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 plot.bar() 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 plt.show() method.
Example
import pandas as pd from matplotlib import pyplot as plt df = pd.DataFrame({'lab': ['A', 'B', 'C'], 'value': [10, 30, 20]}) ax = df.plot.bar(x='lab', y='value', color='#5fba34') plt.show()
Output
- Related Articles
- How To Annotate Bars in Bar Plot with Matplotlib in Python?
- Python Pandas - Draw a set of horizontal bar plots with Seaborn
- How to Annotate Bars in Grouped Barplot in Python?
- How to create plotly bar chart with values on top of bars in R?
- Python Pandas - Draw vertical bar plots with nested grouping by two categorical variables in Seaborn
- Python Pandas - Create a Bar Plot and style the bars in Seaborn
- Python Pandas - Draw a bar plot and set a cap to the error bars with Seaborn
- How to create multiple bar plots for varying categories with same width bars using ggplot2 in R?
- Python Pandas - Draw a set of vertical bar plots grouped by a categorical variable with Seaborn
- How to Annotate Matplotlib Scatter Plots?
- How to create a bar plot with bars for missing values in R?
- Python - Density Plots with Pandas for a specific attribute
- How to create a bar plot in R with label of bars on top of the bars using ggplot2?
- How to write text above the bars on a bar plot (Python Matplotlib)?
- Create a Bar plot with SeaBorn – Python Pandas

Advertisements