Matplotlib – Pie Chart

To plot a pie chart in Matplotlib, use the pie() method. The pyplot.pie() method has the following parameters:

  • The 1st parameter is x, the wedge sizes are set here
  • The labels parameter is the sequence of strings providing the labels for each wedge
  • The third parameter is autopct, a string that labels the wedges with their numeric value. The label will be placed inside the wedge. If autopct is a format string, the label will be fmt % pct

Let us see an example wherein we will plot a pie chart for players scoring runs in a match:

Output

Pie Chart in Matplotlib


If you liked the tutorial, spread the word and share the link and our website Studyopedia with others.


For Videos, Join Our YouTube Channel: Join Now


Matplotlib - Bar Graph
Matplotlib - Histogram
Studyopedia Editorial Staff
contact@studyopedia.com

We work to create programming tutorials for all.

No Comments

Post A Comment

Discover more from Studyopedia

Subscribe now to keep reading and get access to the full archive.

Continue reading