Performing univariate analysis using a pie chart
A pie chart is a circular visual that displays the relative sizes of various categories. Each slice of a pie chart represents a category and each category’s size is proportional to its fraction of the total size of the data, typically 100 percent. Pie charts allow us to easily compare various categories.
In this recipe, we will explore how to create pie charts in matplotlib
. seaborn
doesn’t have a pie chart method for creating pie charts, so, we will use matplotlib
to achieve this. The pie
method in matplotlib
can be used for this.
Getting ready
We will continue to work with the Palmer Archipelago (Antarctica) Penguin data from Kaggle in this recipe.
How to do it…
Let’s learn how to create a pie chart using the matplotlib
library:
- Import the
pandas
andseaborn
libraries:import pandas as pd import matplotlib.pyplot as plt import seaborn as sns
- Load the
.csv
into a dataframe using...