From the course: Python Functions for Data Science
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Matplotlib pie charts - Python Tutorial
From the course: Python Functions for Data Science
Matplotlib pie charts
- [Instructor] Another type of plot that Matplotlib supports is the pie chart. In this video I'll be showing you how to create a pie chart using Matplotlibs functions. Let's say that I have a pandas dataframe containing the weighted components used to give students their grades in a particular course as shown here. Now say, I want to create a pie chart of this data, and I want my pie chart to illustrate the breakdown of students' course grades, such that each category and its corresponding weight is shown. I can use the pie function from the pyplot submodule of Matplotlib. It would look like this. First I'll call the figure function and pass in the keyword argument figsize so that the figure size is seven by seven. Next I'll call the pie function like this. Then I'll call the title function to set the title of the plot. Lastly, I'll call the show function to make sure that the plot gets displayed. And that's it.…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.