10.8 Optional: Plot the Mendley 1998 data

The following section is optional

As we’ll discuss in depth in a later section on plotting , one reason why the ggplot and ggpubr packages are so powerful is because they can easily plot things in good color schemes. We can make a basic scatter plot like this to show the positive correlation between Diatom species richness (the raw number of species identified in a given sample) on the x axis and species diversity on the y axis.

First, load the ggpubr package using the library() command. Note that you might get some output in red text telling you about the packages; it looks scary but its not.

library(ggpubr)

Now plot the scatter plot. Note that the syntax for ggpubr requires that variables be contained within quotes.

ggscatter(data = med98, y = "spp.div",x = "spp.rich")

We can color-code the points by their pH

ggscatter(data = med98, y = "spp.div",x = "spp.rich", color = "pH")

End optional section