Now I could do um,um, more subsets so I can plot them different colors.
Cause here I'm, I'm plotting but the um,the initializing a plot but
then one thing you can see is I added the argument type equals
n and so what type equals n means it basically sets up
the plot and initializes the graphics
device but it doesn't actually plot anything.
So it doesn't put anything into the plotting region.
It just
makes a, it sets up all the other stuff in the plot without the actual data.
And then as I, in order to put the data into
the plot, I kind of go through subsets of the data frame.
To add the data from the month of May, and add data for the month of not May.
So, for the month of May, I make that color blue, and then, for
the other months that are not equal to May, I just make that color red.
So, you can see all of the other points are red.
So now, I can kind of accurately see which ones are blue, which ones are
May, without kind of ov, over plotting existing points.
And then as a last touch, I add a legend to the top right part of the plot, so I
can distinguish, which ones are May, which ones are not May.
Finally, one common thing you will typically want
to do is add a regression line or
a smoother to a plot, so here I've
just added a regression line to this same scatterplot.
So I first make
the scatterplot and you notice, I changed the default.
Plotting character pch to be 20.
So, 20 is a kind of small filled in circle.
And then I fit a linear model to the data, which is using the LM function.
And then I just call the abline function, which
is another annotation function, ah,and I just pass it,
the linear model object and I specify lwd equals
to 2, which is a thicker line than the
typical default line.
So abline can interpret the regression model output and
plot a line, plot with a given intercept and slope.
And so here you can see, I've added the regression line to the plot.
Um,and so you can see,and you can see the downward trend.