- 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
How to plot a bar chart for a list in Python matplotlib?
To plot a bar chart for a list in python matplotlib we can take the following steps.
Steps
Set the figure size and adjust the padding between and around the subplots.
Make a list of data points.
Make a bar plot with data.
To display the figure, use Show() method.
Example
from matplotlib import pyplot as plt # Set the figure size plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True # List of data points data = [0, 1, 3, 2, 1, 5, 2, 1, 4, 2, 4, 0] # Plot bar chart with data points plt.bar(data, data) # Display the plot plt.show()
Output
It will produce the following output −
- Related Articles
- How to plot a Bar Chart with multiple labels in Matplotlib?
- How to plot a very simple bar chart (Python, Matplotlib) using input *.txt file?
- Python - Plot a Pie Chart for Pandas Dataframe with Matplotlib?
- Python Pandas - Plot a Stacked Horizontal Bar Chart
- How to plot a nested pie chart in Matplotlib?
- How to display stacked bar chart using matplotlib in Python?
- How to plot an emoji as a label for a bar in Matplotlib?
- How to display percentage above a bar chart in Matplotlib?
- How to Create a Diverging Stacked Bar Chart in Matplotlib?
- How to create a stacked bar chart for my DataFrame using Seaborn in Matplotlib?
- How to create a Matplotlib bar chart with a threshold line?
- How to plot pie-chart with a single pie highlighted with Python Matplotlib?
- How to make a broken horizontal bar plot in Matplotlib?
- How To Annotate Bars in Bar Plot with Matplotlib in Python?
- How to write text above the bars on a bar plot (Python Matplotlib)?

Advertisements