- 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
Python - Plot a Pie Chart for Pandas Dataframe with Matplotlib?
To plot a Pie Chart, use the plot.pie(). The pie plot is a proportional representation of the numerical data in a column.
Import the required libraries −
import pandas as pd import matplotlib.pyplot as plt
Create a DataFrame −
dataFrame = pd.DataFrame({ "Car": ['BMW', 'Lexus', 'Tesla', 'Mustang', 'Mercedes', 'Jaguar'],"Reg_Price": [7000, 1500, 5000, 8000, 9000, 6000] })
Plot a Pie Chart for Registration Price column with label Car column −
plt.pie(dataFrame["Reg_Price"], labels = dataFrame["Car"])
Example
Following is the code −
import pandas as pd import matplotlib.pyplot as plt # creating dataframe dataFrame = pd.DataFrame({ "Car": ['BMW', 'Lexus', 'Tesla', 'Mustang', 'Mercedes', 'Jaguar'],"Reg_Price": [7000, 1500, 5000, 8000, 9000, 6000] }) # plot a Pie Chart for Registration Price column with label Car column plt.pie(dataFrame["Reg_Price"], labels = dataFrame["Car"]) plt.show()
Output
This will produce the following output −
- Related Articles
- How to plot pie-chart with a single pie highlighted with Python Matplotlib?
- Python - Plot a Histogram for Pandas Dataframe with Matplotlib?
- Plot a Line Graph for Pandas Dataframe with Matplotlib?
- How to plot a nested pie chart in Matplotlib?
- How to plot a Pandas Dataframe with Matplotlib?
- Plot multiple columns of Pandas dataframe on the bar chart in Matplotlib
- Frequency plot in Python/Pandas DataFrame using Matplotlib
- Python - Draw a Scatter Plot for a Pandas DataFrame
- How to label bubble chart/scatter plot with column from Pandas dataframe?
- How to plot an area in a Pandas dataframe in Matplotlib Python?
- How to plot a Pandas multi-index dataFrame with all xticks (Matplotlib)?
- Annotating points from a Pandas Dataframe in Matplotlib plot
- How to plot a bar chart for a list in Python matplotlib?
- Python Pandas - Plot a Stacked Horizontal Bar Chart
- How to plot certain rows of a Pandas dataframe using Matplotlib?

Advertisements