Library - Matplotlib

Back to Course

Lesson Description

Lession - #512 matplotlib Pie Charts

A Pie Chart can show one series of information. Pie outlines show the size of things (called wedge>
in one information series, corresponding to the amount of the things. The data of interest in a pie diagram are displayed as a level of the entire pie.

Matplotlib API has a pie(>
work that creates a pie chart addressing information in an exhibit. The partial region of each wedge is given by x/sum(x>
. In the event that sum(x>
< 1, the upsides of x give the partial region straightforwardly and the cluster won't be standardized. Theresulting pie will have a vacant wedge of size 1 - sum(x>

The pie outline looks best assuming the figure and tomahawks are square, or the Axes viewpoint is equivalent.

Following code utilizes the pie(>
capacity to show the pie diagram of the rundown of understudies selected for different script courses. The proportionate rate is shown inside the individual wedge with the assistance of autopct boundary which is set to %1.2f%.

    from matplotlib import pyplot as plt
import numpy as np
fig = plt.figure(>
ax = fig.add_axes([0,0,1,1]>
langs = ['C', 'C++', 'Java', 'Python', 'PHP'] students = [23,17,35,29,12] ax.pie(students, labels = langs,autopct='%1.2f%%'>