Matplotlib Pie Chart – Tutorial and Examples

python_tutorials

Introduction

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 Axes instance.

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]

 

 

To finish reading, please visit source site