Homework 12

Lindsey Carlson

4/13/2022

Advanced ggplotting

For this exercise, use your newly-developed ggplot chops to create some nice graphs from your own data (If you do not have a good data frame to use for graphics, use one of the many built-in data frames from R (other than mpg, which we are using in class)). Experiment with different themes, theme base sizes, aesthetics, mappings, and faceting. When you are finished, try exporting them to high quality pdfs, jpgs, eps files, or other formats that you would use for submission to a journal.

library(rLakeAnalyzer)
library(readxl)
library(ggplot2)
library(lubridate)
## 
## Attaching package: 'lubridate'
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
library(patchwork)
## Warning: package 'patchwork' was built under R version 4.1.3
library(ggthemes)
## Warning: package 'ggthemes' was built under R version 4.1.3
CarmiSpring <- read_xlsx("LakeData.xlsx", sheet="Spring")
## New names:
## * `` -> ...16
CarmiSpring$Date <- as_datetime(CarmiSpring$Date)

#DO Plots

springDO<-ggplot(CarmiSpring, aes(x=Date, y=DO))+
  geom_point(color="blueviolet")+
  geom_line(color="blueviolet")+
  ylim(7.25,12)+
  labs(x="Date", y="DO (mg/L)", title = "Early Summer")+
  theme_grey()

CarmiSummer <- read_xlsx("LakeData.xlsx", sheet="Summer")
## New names:
## * `` -> ...16
CarmiSummer$Date <- as_datetime(CarmiSummer$Date)

summerDO<-ggplot(CarmiSummer, aes(x=Date, y=DO), )+
  geom_point(color="darkgreen")+
  geom_line(color="darkgreen")+
  ylim(7.25,12)+
  labs(x="Date", y="DO (mg/L)", title = "Mid-Summer")+
  theme_grey()

CarmiFall <- read_xlsx("LakeData.xlsx", sheet="Fall")
## New names:
## * `` -> ...16
CarmiFall$Date <- as_datetime(CarmiFall$Date)

fallDO<-ggplot(CarmiFall, aes(x=Date, y=DO))+
  geom_point(color="darkorange2")+
  geom_line(color="darkorange2")+
  ylim(7.25,12)+
  labs(x="Date", y="DO (mg/L)", title = "Late Summer")+
  theme_grey()

springDO + summerDO + fallDO + plot_layout(ncol=1) + plot_annotation('DO Trends of Lake Carmi, VT', caption = 'Data from VT DEC')

Home Page