Python | Pie Chart with Shadow

In this article, we are going to learn about the pie chart with shadow and its Python implementation.
Submitted by Anuj Singh, on August 01, 2020

A pie plot or a pie chart is a circular statistical graphic technique, in which a circle is divided into slices with respect to numerical proportion. In a pie chart, the arc length, central angle, and area of each slice, is proportional to the quantity it represents. The sum of the total is always equal to 100 percent in the basic pie chart.

The name pie in the pie plot is derived for its resemblance to a pie that has been sliced. Pie charts are very widely used in the different types of projects and business world. Matplotlib has a defined function in

matplotlib.pyplot.pie() for plotting a pie chart. In this tutorial, we are going to add shadow to the pie chart to create a fancy pie chart ready for presentations using an inbuilt command shadow='True'. The following example is an illustration of the same.

Python | Pie Chart with Shadow

Python code for pie chart with shadow

# Data Visualization using Python
# Introducing Shadow Pie Chart

import matplotlib.pyplot as plt

labels = 'A', 'B', 'C', 'D', 'E', 'F'
sizes = [15, 20, 10, 17, 1, 37]
explode = (0, 0.1, 0, 0, 0, 0)

plt.figure()
plt.pie(sizes, labels=labels, explode=explode, autopct='%1.1f%%', shadow=True)
plt.axis('equal') 
plt.show()

Output:

Output is as figure





Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.





Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.