 As we go through our necessarily very short presentations on basic graphics, I want to finish by saying one more thing. And that is you have the possibility of overlaying plots. And that means putting one plot directly on top of or superimposing it on another. Now you may ask yourself why you want to do this. Well, I can give you an artistic version on this. This, of course, is Pablo Picasso's Le Demoiselle de Avignon. And it's one of the early masterpieces in Cubism. And the idea of Cubism is it gives you many views, or it gives you simultaneously several different perspectives on the same thing. And we're going to try to do a similar thing with data. And so we can say very quickly, thanks Pablo. Now, why would you overlay plots? Really, if you want the technical explanation, it's because you get increased information density, you get more information, and hopefully more insight in the same amount of space and hopefully the same amount of time. Now, there is a potential risk here, you might be saying to yourself at this point, well, you want dense? Guess what? I can do dense. And then we end up with something vaguely like this, the Garden of Earthly Delights, and it's completely overwhelming. And it's just makes you kind of shut down cognitively. And you know, thank you, Hieronymus Bosch. No, instead, while I like Hieronymus Bosch's work, I'm gonna tell you, when it comes to data graphics, use restraint, just because you can do something doesn't mean that you should do that thing. When it comes to graphics and overlaying plots, the general rule is this, use views that complement and support one another that don't compete, but that give greater information in a coherent and consistent way. This is going to make a lot more sense if we just take a look at how it works in R. So open up this script, and we'll see how we can overlay plots for greater information density and greater insight. The first thing that we're going to need to do is open up the data sets package. And we're going to be using a data set we haven't used before about links is that's the animal. This is about Canadian links trappings from 1821 to 1934. If you want the actual information on the data set. There it is. Now let's take a look at the first few lines of data. This one is a time series. And so what's unusual about it is it's just one line of numbers. And you have to know that it starts at 1821 it goes through. So let's make a default chart with a histogram as a way of seeing where links trappings consistent or how much variability was there. We'll do his which is the default histogram and we'll simply put links in. We don't have to specify variables because there's only one variable in it. And when we do that I'll zoom in on that. We get really a skewed distribution. Most of the observations are down at the low end. And then it tapers off to actually measured in 1000s. And so we can tell that there is a very common value is at the low end. And then on the other hand, we don't know what years those were. So we're ignoring that for just a moment and taking a look at the overall distribution of trappings regardless of years. Let me zoom back out. And we can do some options on this one to make it a little more intricate. We can do a histogram. And then if in parentheses, I specify the data, I also can tell it how many bins I want. And again, it sort of is suggesting it because ours going to do what it wants any how I can say make it a density instead of frequency. So it'll give proportions of the total distribution will change the color to called thistle one because you can use color names in our will give it a title here. By the way, I'm using the paste command because it's a long title. And I want it to show up on one line, but I need to spread my command across two lines. You can go longer. I have to use a short command line so you can actually see what we do when we're zoomed in here. So there's that one. And then we're going to give it a label that says number of links trapped. And now we have a more elaborate chart I'll zoom in on it. It's a kind of little thistle purple lilac color. And we have divided the number of bins differently. Previously, it was one bar for every 1000. Now it's one bar for 500. But that's just one chart. We're here to see how we can overlay charts and a really good one anytime you're dealing with a histogram is a normal distribution. So you want to see are the data distributed normally. Now we can tell they're skewed here, but let's get an idea of how far they are from normal. To do this, we use the command curve. And then D norm is for density of the normal distribution. And then here I tell it x is you know, just a generic variable name, but I tell it use the mean of the links data, use the standard deviation of the links data. We'll make it a slightly different thistle color. Number four, we'll make it two pixels wide the line with his two pixels and then adds as stick it on the previous graph. And so now I'll zoom in on that. And you can see if we had a normal distribution with the same mean and standard deviation of this as this data, it would look like that. Obviously, that's not what we have because we have this great big spike here on the low end. Then I can do a couple of other things. I can put in what are called kernel density estimators. And those are sort of like a bell curve, except they're not parametric. Instead, they follow the distribution of the data. That means they can have a lot more curves in them. They still add up to one like a normal distribution. So let's see what those would look like here. We're going to do lines. That's what we use for this one. And then we say density, that's going to be the standard kernel density estimator. We'll make it blue. And there it is on top, I'm going to do one more than we'll zoom in. I can change a parameter of the kernel density estimator here, I'm using adjust to say average across it's sort of like a moving average, average across a little more. And now let me zoom in on that. And you can see, for instance, the blue line follows the spike at the low end a lot more closely, and then it dips down. On the other hand, the purple line is a lot more slow to change because of the way I gave it is instructions with the adjust equals three. And then I'm going to add one more thing something called a rug plot. It's a little vertical lines underneath the plot for each individual data point. And I do that with rug. And I say just use links. And then we're going to make it a line with our pixel width of two, and then we'll make it gray. And that I'm assuming is our final plot, you can see now that we have the individual observations marked and you can see why each bar is as tall as it is and why the kernel density estimator follows the distribution that it does. This is our final histogram with several different views of the same data. It's not cubism, but it's a great way of getting a richer view of even a single variable that can then inform the subsequent analysis you do to get more meaning and more utility out of your data.