Matplotlib Pie Chart – Tutorial and Examples
There are many data visualization libraries in Python, yet Matplotlib is the most popular library out of all of them. Matplotlib’s popularity is due to its reliability and utility – it’s able to create both simple and complex plots with little code. You can also customize the plots in a variety of ways.
In this tutorial, we’ll cover how to plot a Pie Chart in Matplotlib.
Pie charts represent data broken down into categories/labels. They’re an intuitive and simple way to visualize proportional data – such as percentages.
Plot a Pie Chart in Matplotlib
To plot a pie chart in Matplotlib, we can call the
pie() function of the PyPlot or
The only mandatory argument is the data we’d like to plot, such as a feature from a dataset:
import matplotlib.pyplot as plt
x = [15, 25, 25, 30, 5]