 So let's add some layers So you can see this plot that the function from get fly that I've had before And I'm just going to add these layer functions and they are separated by commerce. So there's my first layer Here's my second layer. It's separated by commerce and it takes arguments inside of parentheses So what can I do? Inside of this I just use what I would have used for my plotting So I have my aesthetics x equals x vales to y equals y vales to and the geometry I want for those sets of values is the point and in the second layer I want them sorted so I'm passing the sort function to the values as the aesthetic before I actually plot some points on them as well so two sets of plots actually that I layer on top of each other and There you see them. Only problem is they all colored in blue I can't really distinguish between these two layers that I've added to my plot Now I can add some extra arguments to these layer Functions here, but an easy way to get to get to it is just to to do some themes Now let's do this I'm going to have my two layers again layer and layer and The first one is x vales and y vales as to as far as my aesthetics are concerned a Geom point in my second layer exactly what I've had before but I'm adding a theme and The theme takes a lot. There are a lot of arguments and depending on the type of geometry you use You can introduce certain themes and some arguments to the themes use work for all plots what we are going to pass here as default color and Because it's inside of this layer. It's only going to put pertain to these little point geometries of these aesthetics in this layer And I'm passing passing it this value colorant Orange, so there's a certain colors that you can use their words otherwise you can use hexadecimal values Just with the hashtag But this instance, I'm going to use orange. Let's look at what the What the output looks like now I can distinguish between the two layers The first one was this deep sky blue. That's what this blue is called in case you were wondering deep sky blue all one word and The second layer is now going to have a default color called orange show all the geometry and in this instance It's the point point geometry is going to be colored orange now. I can distinguish the two sets of points Now I want to show you just to add a legend because as you can see by default the default here there's no legend not for these point plots or scatter plots and With that I also just want to show you a different late use to wait to use the layers You can use a layer layers like this just to add a layer to a computer variable So I'm going to call it points one and points two and points one is layer My X and Y aesthetics as point and it has a theme and that default color is color into deep sky blue That's what it was anyway and points two is another layer In parentheses all the arguments that I would have done before its point and theme default color color and orange Note there's no parentheses. That's colorant orange and instead of orange as I said you can use hashtag and in the hexadecimal values Now I can invoke the plot function and instead of layers I've got points one and points two which refer to those layers and this is how I'm going to add This is how I'm going to add just that little key to the side and I use this keyword called guide so that's a new one guide dot manual underscore color key and It takes parentheses. It's a function and it takes various arguments the first argument that it's going to take is just the The title legend for this plot is what I'm going to call the this the the legend comma and then you see we've got this list in square brackets Set of points sorted set of points so I can actually pass string values To the legend that I'm going to use so the blue These blue dots are going to be called set of points because that was the first lot that was mentioned the first layer That was mentioned. There's a second layer mentioned. So that's going to take this String sorted set of points and then comma the last argument that it takes is you can actually specify the colors So again, I stuck to deep sky blue and orange there. So I passed deep sky blue and orange to my legend Now let's have a look at that. So we're going to get exactly the same plot as we had before But now we have this legend and I specified this text legend for this plot I specified this text set of points and sorted set of points and I specified these two colors all in this guide Dot manual color key. So great. Now you can add legends to your plot now one thing is this This grid That we have here I can actually specify the color of this grid So I'm going to do just go back to an easy one just with two layers again The second one being orange but inside of the theme which applies to the whole plot this time Look that it's outside of this layer this layer with its open and closed parentheses there So it's going to apply to the whole it's going to apply to the whole of the Plot and instead see in this one. I've got these dotted gray lines now. It's all white the background is all white and You can pass a different color to it now If I if I hover over it, it's still going to come up But when I move away, I've changed the color to white So you don't see those dotted lines later on I'll show you another way of getting rid of that by just Decreasing the size of it really to zero, but you can see the difference Grid color that is not the background color. That's this these gray lines If I move away, they're white and you can't see them. They are still there and In this instance when I move away, they're actually visible as this light gray So I can also change this mouse over color To white as well that will make them disappear as well. Let's do that So everything stayed state the same. I'm also changing the grid color focused Argument in this the steam's argument to white as well So that's one kind of cheating way of getting rid of even if I mouse over now If I did a mouse over there, you can see the lines appear if I do now they do appear But they just white they the same as the back default background color of my plot Now let's just increase a line thickness a bit using another argument that we find inside a theme So we the aesthetics that we're gonna pass as X as X Vels 2 Ys Y Vels 2 is point I want this a line in there as well But I want a linear model as far as At least like like least squares line that I've got in there linear model line And I can specify inside of the theme line width and I want it to be for px That's four pixel. You've got to put the units in you can use inches centimeters I think there's quite a few things. So we've had this plot before but inside of the theme I can actually just make this whole line a lot thicker Good last thing I just wanted to look at with these themes We'll get to add a lot more things to themes later, but just as an introduction. We can also Change the colors now look what I've done here So it's plot with a layer the first layer is Going to be a point geometry with this these aesthetics And it has a theme with a default point size of 10 pixels instead of these small little ones Which are the default I'm going to increase that in the second layer. I'm passing the same I'm passing exactly the same aesthetics, but I'm doing this linear model line called smooth Method equals colon lm for line and the theme I passed to that is a line width of four pixels and a different color This time I'm doing default color equals colorant orange So I think you can well imagine what this is going to look like So what I've done now is I've changed the default size of this in the theme of the first layer The second layer is this linear model line and I've made it thicker with line width So you can see this line with there and the default color so Looks quite spectacular there Last thing quickly for this lecture for this section is I'm just going to add some labels We've seen how to add our legend But we can also introduce this new keyword called guide guide the title guide that X label guide that Y label And as you can well imagine that is just going to put some text The title and X and Y so you see the aesthetic that I passed there and the geometry was point But now I've got my title my scatter plot That's the text that I use and X values and Y values with the two strings of that I passed here Lastly if you want to save your plots, of course, this is I Julia inside of a Jupiter notebook I can Do various things, but if I want to use Julia just to save these plots. I'm going to import this Cairo package using Cairo and I'm just going to import Distributions as well because I've created a little plot here there You see the plot and I'm using some distributions there Don't be don't be concerned about that stat and all sorts of things that I'm using here It's just a normal plot function. So don't worry. What's inside of there? But inside of Cairo, I have this draw function draw It takes arguments the first argument PNG because I want a PNG portable network graphic file format for my plot I'm give it a name and I can specify the size in either pixel size or inches or centimeters Yeah, I've chosen eight inches by six inches comma and then it takes the actual plot So you can do it all in one as I've done here And if I run this nothing is going to happen but if I were to go back, I suddenly see there does my QQ plot has appeared and Depending on the browser that you use you can actually print that To the screen, but it will save that for you in this instance We're using Julia box so I can go into my files here and sync and I can actually download it to my computer Good and the next section we're going to import a data frame And that's what we're interested in get fly as data away so I can actually plot some data straight from a data frame