top of page

Python Data Analysis Tips - Pandas' Pie Plot, explode sections, highlight edges

Updated: Aug 21, 2023


free, Instruct, instructional, instructional education,free python learn, seaborn, python, data analysis, analysis, pieplot, analyze, statical analysis, distribution
Pandas Pie Plot


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:










free, Instruct, instructional, instructional education,free python learn, seaborn, python, data analysis, analysis, pie plot, pandas, explode, analyze, statical analysis, distribution
Pie Plot to plot counts of values

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.



free, Instruct, instructional, instructional education,free python learn, seaborn, python, data analysis, analysis, pie plot, pandas, explode, analyze, statical analysis, distribution
Add percentages to Pie Plot so easier to tell proportions

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


free, Instruct, instructional, instructional education,free python learn, seaborn, python, data analysis, analysis, pie plot, pandas, explode, analyze, statical analysis, distribution
plt.title to add a title

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.



free, Instruct, instructional, instructional education,free python learn, seaborn, python, data analysis, analysis, pie plot, pandas, explode, analyze, statical analysis, distribution
the explode arguement to highligh a section in pieplot

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.


free, Instruct, instructional, instructional education,free python learn, seaborn, python, data analysis, analysis, pie plot, pandas, explode, analyze, statical analysis, distribution
Patches to can high edge color

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

313 views0 comments

Recent Posts

See All

Comments

Rated 0 out of 5 stars.
No ratings yet

Add a rating
bottom of page