
Learn our to make a pie plot in Python. Here we use Pandas' plot which will give us access to the pie plot. In general data scientists aren't a fan of pie plots. The reason for this is that although it is easy to tell which sections are bigger it is very difficult to understand how much bigger one section is versus the other.
To deal with the issue will set each wedge to contain the percentage it makes up of the whole pie.
We later access the patches of our plot and add highlight the edges to give a little more polish to our pie plot.
Follow Data Science Teacher Brandyn
dataGroups:

Pandas' plot of top of value_counts function in pandas allows us to plot the proportion each category arises in the feature use the pie plot on top of value_counts.

Add percentages to better understand the proportion of each value or category in our pie plot.

We can use the plt title function to plot the title on top of pandas plots as basically Pandas' is using matplotlib to plot and so formating is as easy as calling the matplotlib functions.

An arguement that helps us highlight different sections or wedges in our pie plot is the explode argument that allows us to control how much separation the is between each section or wedge in our pie plot.

Accessing the patches attribute allows us to iterate through the wedges in our pie plot and highlight the outside edge in our pie plot.
Comments