Hello and welcome to a module on box plots in Python. First let's load in some data and we'll import all the libraries
we'll be using. We're not going to talk about these first two libraries very much because we've talked about them already
and we've used them in a couple of assignments by now. But these are how you load in your data.
The next library that we're importing is Matplotlib.pyplot and we're importing that as PLT to make it easier
for us to use in our code below. That way we don't have to type Matplotlib.pyplot
over and over. So the next lines of code we have here are just
mounting our drive, setting our file path, and then reading that file path into a data frame that we are calling
DF. I've already printed out the head of that data down below. So you can see that we're just using the class data again
this time. We're going to make a box and whisker plot for DV. So let's go ahead
and do that. To create the box plot, all we have to do is call plt.boxplot.
Pretty simple. We tell it what variable we'd like to use. In this case, we're
using the variable DV from our data frame df. We are going to set patch artist equal to
true, because we'd like to fill in our box plot with color. If you want to just an outline for your box plot,
you would set this to false or ignore it entirely, because by default, it is set to false.
This next line lets it know what color we would like to fill in our box plot
with. Next, we'll add a title. plt.title will
add a title to your box plot. plt.ylabel will set a y label for your box plot and plt.xlabel
would set the x label but we're not going to set one today. Last, not
least, we use plt.show to actually show the box plot. So let's go ahead and run it.
Okay, there we have it, a sky blue box and whisker plot. That's pretty much all there is to it.