Python code to draw a pie chart; Through this tutorial, i am going to show you how to make pie chart in python using Matplotlib pie chart.
Python Code to Draw a Pie Chart
- Import pyplot module from the matplotlib library.
- Take the daily activity and time taken to do the activity in two arrays.
- Finally, draw the pie chart with the title ‘Activity Chart’.
# Python Program to Draw a Pie Chart import matplotlib.pyplot as plt A=['eat', 'movie', 'study', 'play','daily_work','sleep'] T=[2,4,6,7,8,9] plt.pie(T, labels=A,autopct= '%1.1f%%') plt.title('Activity Chart.') plt.show()
Recommended Python Tutorials
Recommended:-Python Program to Convert cm to Feet and Inches
Recommended:-How to Reverse a List in Python
Recommended:-Python Program to Convert Celsius to Fahrenheit
Recommended:-Python Program to Find Standard Deviation
Recommended:-Python Program to Check Perfect Number
Recommended:-Python Program to Display Calendar
Recommended:-Python Program to Print Alphabets from A to Z
Recommended:-Python Program to Find Roots of Quadratic Equation
Recommended:-Python Program to Find the Variance
Recommended:-How to Check Python Program Execution Time
Recommended:-Python Program Find Day of Week For Given Date
Recommended:-Python Program to Print Sum of All Array Elements
Recommended:-Python Program to Find the GCD of Two Numbers
Recommended:-Python Program to Find the LCM of the Array Elements