1 00:00:00,333 --> 00:00:02,166 2 00:00:02,166 --> 00:00:08,566 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 3 00:00:08,566 --> 00:00:08,599 4 00:00:08,600 --> 00:00:14,700 we'll be using. We're not going to talk about these first two libraries very much because we've talked about them already 5 00:00:14,700 --> 00:00:14,733 6 00:00:14,733 --> 00:00:20,299 and we've used them in a couple of assignments by now. But these are how you load in your data. 7 00:00:20,300 --> 00:00:21,400 8 00:00:21,400 --> 00:00:27,733 The next library that we're importing is Matplotlib.pyplot and we're importing that as PLT to make it easier 9 00:00:27,733 --> 00:00:33,933 for us to use in our code below. That way we don't have to type Matplotlib.pyplot 10 00:00:33,933 --> 00:00:34,266 11 00:00:34,266 --> 00:00:40,399 over and over. So the next lines of code we have here are just 12 00:00:40,400 --> 00:00:46,566 mounting our drive, setting our file path, and then reading that file path into a data frame that we are calling 13 00:00:46,566 --> 00:00:52,666 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 14 00:00:52,666 --> 00:00:52,699 15 00:00:52,700 --> 00:00:58,733 this time. We're going to make a box and whisker plot for DV. So let's go ahead 16 00:00:58,733 --> 00:01:05,333 and do that. To create the box plot, all we have to do is call plt.boxplot. 17 00:01:05,333 --> 00:01:05,499 18 00:01:05,500 --> 00:01:11,566 Pretty simple. We tell it what variable we'd like to use. In this case, we're 19 00:01:11,566 --> 00:01:11,599 20 00:01:11,600 --> 00:01:17,666 using the variable DV from our data frame df. We are going to set patch artist equal to 21 00:01:17,666 --> 00:01:17,699 22 00:01:17,700 --> 00:01:23,933 true, because we'd like to fill in our box plot with color. If you want to just an outline for your box plot, 23 00:01:23,933 --> 00:01:29,999 you would set this to false or ignore it entirely, because by default, it is set to false. 24 00:01:30,000 --> 00:01:32,333 25 00:01:32,333 --> 00:01:38,499 This next line lets it know what color we would like to fill in our box plot 26 00:01:38,500 --> 00:01:44,533 with. Next, we'll add a title. plt.title will 27 00:01:44,533 --> 00:01:44,566 28 00:01:44,566 --> 00:01:50,699 add a title to your box plot. plt.ylabel will set a y label for your box plot and plt.xlabel 29 00:01:50,700 --> 00:01:56,833 would set the x label but we're not going to set one today. Last, not 30 00:01:56,833 --> 00:02:01,933 least, we use plt.show to actually show the box plot. So let's go ahead and run it. 31 00:02:01,933 --> 00:02:07,066 32 00:02:07,066 --> 00:02:12,499 Okay, there we have it, a sky blue box and whisker plot. That's pretty much all there is to it.