 So here we are in another tutorial. We're going to talk about the box and whisker plot and it is a very common type of plot to use and quite informative. Now we're going to import the cascading style sheet style.css as we usually do and let's set up our plotly library here. So from plotly.offline we import iplot and initialize notebook mode and we actually call that function in it notebook mode so that we can plot directly inside of the Jupyter notebook. And again we're going to use high level charts. The box plot is a high level chart so from plotly.graph objects or graph underscore obj's we're going to import that as go. So let's import numerical python because we're going to use that and we get going to see the pseudo random number generator so that we can get the same random values every time. So I'm going to create three computer variables here. Let's just increase the screen size here so you can see properly. We have group A, group B and the control group and I'm going to draw 500 values each time. As you can see the size argument here from a normal distribution with a mean of 100 in the first instance and a standard deviation of 10. So the keyword arguments they are LOC and scale, a mean of 110 and the standard deviation of 15 and a mean of 105 and a standard deviation of 20. So we're just creating these three lists or arrays at least of 500 numbers each. So let's do a simple box plot. Again we're going to have a trace and our high level chart is this box. So it's go.box and on the y-axis we want the groups. The data is then a list of all the traces. We only have a single trace and we use this key data pair, key value pair here in a dictionary just to do the eye plot. And there we go and it's because we said y equals group A. So on the y-axis here we have all the levels and that gives us this vertical box plots. So if I hover over there we can see a maximum. We can see a minimum. We can see the whiskers, the upper and lower fences there. We can see the medium and the first and third quartile values there. We can also see these outlines that are beyond the whiskers and I can actually hover over them and we can see those values as well. So let's just do more than one data set and the way that we're going to do that is in a pythonic way. So this is something new I haven't shown you before. Let's increase the size one more time so it's nice and clear. So I'm going to have this mt list here called trace and I'm going to have values inside of a list the python list group A group B and control group. Those are the arrays that I created above and then groups I'm going to have this list of strings group A, group B and group C. So I'm going to use a little for loop. So I'm going to say for I in range zero to the length of the groups. So the groups here is one, two, three. So it's going to go from zero to three which in Python language means zero, one and two. So it's going to loop through a zero instance, a one instance and a two instance. So I'm going to append to this trace empty list, a box and the y is going to be val's i. So the first one is val's zero, val zero is group A. So I'm going to say y equals group A and the name equals the first one or the zero with one here in this groups list. So there'll be group A and my data is going to be a trace. Now I'm going to run through this three times. So I'm actually going to have just to have three traces and this trace is a list. It's inside of square brackets. So I'm just going to have all of them there. So I hope you can see what's going on with this for loop. It's a Pythonic way of handling this instead of making three traces. I'm making one single. I'm doing it once in a for loop. So if I were to run that, well, let's just run our three values there, our three computer variables say, and then run our for loop. And now we can see we've got three traces named group A, group B and group C. And we've plotted each of them. No problem. Now let's go through this again. And what we're going to say here, the only difference we're going to make is that we're going to do box plot equals outliers. So it's another argument that I'm adding to this box chart that I'm creating here. And although it's no different from what we've seen there, we've just explicitly said that we want these outliers now to be identified properly. I can also say, now admit the outliers, and then these will disappear. They won't be shown here at all. Now they're more than one ways of doing horizontal box plots. But the easiest way is just to change from the y axis to the x axis. So that's the only thing that I'm changing here is to say that this must now be on the x axis. And we see these values of my variables are now in the y axis making these box plots horizontal. No problem whatsoever. Now instead of just these outliers, we can actually have all the box plots in there. And another argument I'm going to add here is box points. And I'm going to say all, I'm going to add a jitter of 0.2 and a point position of negative 1.5. Let me show you what that ends up being. There we go. It just shows all those 500 points in here. The jitter means it's not down a straight line, which means you usually can't see them. I'm making them left, right, left, right, left, right. There's a bit of jitter on the axis here, just so that they can see them all. And the point position is negative 1.5. So that means on the left, just move them slightly away from this little box plot that we have here. And now we see all the box points, all the values plotted there. I can add a mean. So another argument that I'm adding here is box mean. Because remember what we see here in the middle is the median. We can also add the mean. Let's do that. And that'll draw this little horizontal line. I hope you can see it there. Which, because we've taken this from normal distributions, there's not going to be much difference between the mean and the median for all three of these. We can also do the mean and the standard deviation by setting box mean equal to this sd. If we run that, we can see that we have the mean and we have the standard deviation out here on this dotted line. Let's play with the line colors. So nothing really changed. I'm going to introduce line. And that's a dict with a color. And we're going to make this black, 0, 0, 0. There we go. That's this black with a width of 1. We're not going to show the legends. So I can also take away the legend that we have here on the side. Let's run that. And there we see that everything is now in this gray scale, which perhaps is a better way to submit for publication. We can actually have a lot of control over what happens. And in this instance, I'm making my line black again. My full color is just I'm going to iterate over with this for loop. And every time I'm going to change that. So that's a dark gray, middle gray and a lighter gray. So that is the full color for this line, which I didn't specify there. And I'm also going to have the marker, the outliers. I'm going to specifically change the color of the outliers. And this is a bit of an orange. And I'm going to use this open circle, one of the key value pairs inside of this dictionary, a symbol, and then also the size. So a lot of things that I can really play with. And if we look at this, this is actually quite beautiful. We have our dark gray, our middle gray, and our light gray, as I said there. And our outliers here are these 10 point sized open circles that are colored in orange. So really a lot that you can play with when dealing with with these with these box plots.