- 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 graph in Matplotlib from a Pandas series?
To plot a bar graph from a Pandas series in matplotlib, we can take the following Steps −
Make a dictionary of different keys, between the range 1 to 10.
Make a dataframe using Pandas data frame.
Create a bar plot using plot() method with kind="bar".
To display the figure, use show() method.
Example
import pandas as pd from matplotlib import pyplot as plt plt.rcParams["figure.figsize"] = [7.00, 3.50] plt.rcParams["figure.autolayout"] = True d = {'y=1/x': [1 / i for i in range(1, 10)], 'y=x': [i for i in range(1, 10)], 'y=x^2': [i * i for i in range(1, 10)], 'y=x^3': [i * i * i for i in range(1, 10)]} df = pd.DataFrame(d) df.plot(kind='bar') plt.show()
Output
- Related Articles
- Python - How to plot a Pandas DataFrame in a Bar Graph
- How to give a Pandas/Matplotlib bar graph custom colors?
- How to show a bar and line graph on the same plot in Matplotlib?
- Plot a Line Graph for Pandas Dataframe with Matplotlib?
- How to plot a line graph from histogram data in Matplotlib?
- How to plot arbitrary markers on a Pandas data series using Matplotlib?
- Plot multiple time-series DataFrames into a single plot using Pandas (Matplotlib)
- How to plot a high resolution graph in Matplotlib?
- How to make a broken horizontal bar plot in Matplotlib?
- How to plot multiple Pandas columns on the Y-axis of a line graph (Matplotlib)?
- Annotating points from a Pandas Dataframe in Matplotlib plot
- How to plot a Pandas Dataframe with Matplotlib?
- Dynamically updating a bar plot in Matplotlib
- Plot multiple boxplots in one graph in Pandas or Matplotlib
- How to plot a bar chart for a list in Python matplotlib?

Advertisements