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 bar plots - Python Tutorial
From the course: Python Functions for Data Science
Matplotlib bar plots
- [Instructor] Matplotlib's pie plot sub-module has the tools to create bar plots. I'll be walking through an example to demonstrate how to create a bar plot of your data in Python. Let's say that I have a Pandas data frame containing the means per five exams taken by a set of students as shown here. Now say that I want to create a bar plot of this data. I want to plot mean versus exam. First, I'll call the bar function, and I'll pass in the exam column and the mean column from the exam means data frame in that order. Next I'll call the X label function and pass an exam. This will set the label of the X axis to exam. Then I'll call the Y label function and pass in mean. This will set the label of the Y axis to mean. Lastly, I'll call the show function to make sure that the plot gets displayed. There we go. Keep the bar function in mind when you want to create bar plots of your data.
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.