
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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 Questions & Answers
- 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 Pandas - Plot a Stacked Horizontal Bar Chart
- Python - Plot a Pie Chart for Pandas Dataframe with Matplotlib?
- How to plot a nested pie chart in Matplotlib?
- How to display percentage above a bar chart in Matplotlib?
- How to Create a Diverging Stacked Bar Chart in Matplotlib?
- How to plot an emoji as a label for a bar in Matplotlib?
- How to create a Matplotlib bar chart with a threshold line?
- How to create a stacked bar chart for my DataFrame using Seaborn in Matplotlib?
- How to display stacked bar chart using matplotlib in Python?
- Adding value labels on a matplotlib bar chart
- Dynamically updating a bar plot in Matplotlib
- How to make a broken horizontal bar plot in Matplotlib?
- Horizontal stacked bar chart in Matplotlib
Advertisements