Click here to return to the homepage
Make ggplot graph of own data!
library(ggplot2)
library(wesanderson)
library(tidyverse)
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v tibble 3.1.6 v dplyr 1.0.7
## v tidyr 1.2.0 v stringr 1.4.0
## v readr 2.1.2 v forcats 0.5.1
## v purrr 0.3.4
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag() masks stats::lag()
setwd("C:/Users/steph/OneDrive - University of Vermont/Documents/Dissertation_Research/StreamCarbon") #Set working directory to get data
streamC <- read.csv("combined_r_table_oldgrowth_hbef_lineintercept_carbon.csv")
head(streamC)
## ï..id site age_class stream_names vol_m3_ha vol_cm3_ha biomass_g_ha
## 1 1 HBEF mature w7 64.35805 64358045 20916365
## 2 2 HBEF mature kineo1 69.04200 69041995 22438648
## 3 3 HBEF mature zigzag 16.14092 16140916 5245798
## 4 4 HBEF mature cushman 54.28282 54282824 17641918
## 5 5 HBEF mature crazy 25.70209 25702095 8353181
## 6 6 HBEF mature w9 22.72065 22720652 7384212
## carbon_g_ha carbon_Mg_ha
## 1 10264706 10.264706
## 2 11011767 11.011767
## 3 2574375 2.574375
## 4 8657771 8.657771
## 5 4099323 4.099323
## 6 3623802 3.623802
p1 <- ggplot(data = streamC, aes(x = age_class, y = carbon_Mg_ha)) +
geom_boxplot(outlier.color = "black", fill = wes_palette("Royal1", n = 2)) +
ggtitle("Carbon Storage of In-stream LWD") +
xlab("Riparian Forest Age Class") +
ylab ("Carbon (Mg/ha)") +
scale_x_discrete(labels=c("Mature","Old Growth")) + # change factor names
theme_classic() +
theme(plot.title = element_text(hjust = 0.5)) + # center plot title
annotate("text", x = "oldgrowth", y = 5, label = "p < 0.01") + #add p value
annotate("text", x = "mature", y = 30, label = "*") + # add asterisk to denote significance
annotate("text", x = "oldgrowth", y = 30, label = "**") + # add double asterisk to denote different significance
scale_y_continuous(breaks = seq(0, 30, 5))
print(p1)
#ggsave("LWD_Carbon_by_ageclass1", plot = p1, device = "pdf", width = 10, height = 10)