#Setup Graph 1
library(dplyr)
##
## Attaching package: 'dplyr'
## The following objects are masked from 'package:stats':
##
## filter, lag
## The following objects are masked from 'package:base':
##
## intersect, setdiff, setequal, union
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 4.0.4
View(economics)
attach(economics)
#Graph 1
ggplot(economics, aes(x = date, y = (unemploy/pop)*100))+
geom_line(color = "red", size = 0.5)+
theme_classic()+
ggtitle("Percent Unemployment Between 1965-2015")+
labs(x = "Date", y = "Percent Unemployed")+
scale_y_continuous(expand = c(0, 0), breaks = c(1, 2, 3, 4, 5, 6), limits = c(0, 7), labels = c("1%", "2%", "3%", "4%", "5%", "6%"))+
scale_x_date(expand = c(0,0), breaks = as.Date(c("1965-01-01", "1970-01-01", "1975-01-01", "1980-01-01", "1985-01-01", "1990-01-01", "1995-01-01", "2000-01-01", "2005-01-01", "2010-01-01", "2015-01-01")), limits = as.Date(c("1965-01-01", "2016-01-01")), labels = c("1965", "1970", "1975", "1980", "1985","1990", "1995","2000", "2005", "2010","2015"))+
theme(axis.title.x = element_text(size = 12, colour = "blue"))+
theme(axis.title.y = element_text(size = 12, colour = "blue"))+
theme(axis.text.x = element_text(colour = "black"))+
theme(axis.text.y = element_text(colour = "black"))+
theme(plot.title = element_text(face = "bold", size = 16, colour = "blue"))
#Setup Graph 2
library(readr)
runoff <- read.csv("C:/Users/jmhp2/OneDrive/Desktop/ggplot2_pretty/runoff_data_by_month.csv")
#Graph 2
runoff$month <- ordered(runoff$month, levels=c("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"))
ggplot(runoff, aes(x = month, y = runoff, fill = month))+
geom_boxplot()+
theme_classic()+
ggtitle("Monthly Runoff, Fenrow Experimental Forest, Parsons, W.Va.")+
labs(x = "Month", y = "Ronoff (mm)")+
scale_y_continuous(expand = c(0, 0), breaks = c(0, 50, 100, 150, 200, 250, 300), limits = c(0, 300), labels = c("0mm", "50mm", "100mm", "150mm", "200mm", "250mm", "300mm"))+
theme(axis.title.x = element_text(size = 12, colour = "blue"))+
theme(axis.title.y = element_text(size = 12, colour = "blue"))+
theme(axis.text.x = element_text(colour = "black"))+
theme(axis.text.y = element_text(colour = "black"))+
theme(plot.title = element_text(face = "bold", size = 14, colour = "red"))+
theme(axis.title = element_text(size = 14, colour = "black"))+
theme(legend.position = "None")+
theme(panel.grid.major.y = element_line(colour = "grey40", linetype = "dashed"))
#Setup Graph 3
library(gapminder)
## Warning: package 'gapminder' was built under R version 4.0.4
View(gapminder)
attach(gapminder)
## The following object is masked from economics:
##
## pop
#Graph 3
A <- gapminder %>% dplyr::filter(year == "2007")
ggplot(A, aes(x = gdpPercap, y = lifeExp, colour = continent, size = pop))+
geom_point()+
theme_gray()+
ggtitle("Life Expectancy and Population Density by Continent 2007")+
labs(x = "GDP per Capita", y = "Life Expectancy in Years", colour = "Continent", size = "Population")+
scale_x_continuous(expand = c(0, 0), breaks = c(0, 10000, 20000, 30000, 40000, 50000), limits = c(0, 50000), labels = c("0", "10000", "20000", "30000", "40000", "50000"))+
theme(axis.title.x = element_text(size = 12, colour = "blue"))+
theme(axis.title.y = element_text(size = 12, colour = "blue"))+
theme(axis.text.x = element_text(colour = "black"))+
theme(axis.text.y = element_text(colour = "black"))+
theme(plot.title = element_text(face = "bold", size = 16, colour = "red"))+
theme(axis.title = element_text(size = 14, colour = "black"))
#Graph 4
B <- gapminder %>% dplyr::filter(continent == "Africa" | continent == "Europe")
C <- B %>% dplyr::filter(year == "1977" | year == "2007")
ggplot(C, aes(x = gdpPercap, y = lifeExp, size = pop))+
geom_point()+
theme_gray()+
facet_grid(year ~ continent)+
ggtitle("Life Expectancy and Population Density, Africa and Europe 1977 & 2007")+
labs(x = "GDP per Capita", y = "Life Expectancy in Years", size = "Population")+
scale_x_continuous(expand = c(0, 0), breaks = c(0, 10000, 20000, 30000, 40000, 50000), limits = c(0, 50000), labels = c("0", "10000", "20000", "30000", "40000", "50000"))+
scale_size_continuous(breaks = c(5e+04, 1e+05, 1e+06, 1e+07, 1e+08, 1.5e+08), limits = c(5e+04, 1.5e+08), labels = c("50 Thousand", "100 Thousand", "1 Million", "10 Million", "100 Million", "150 Million"))+
theme(axis.title.x = element_text(size = 12, colour = "blue"))+
theme(axis.title.y = element_text(size = 12, colour = "blue"))+
theme(axis.text.x = element_text(angle = 45, hjust = 1, colour = "black"))+
theme(axis.text.y = element_text(colour = "black"))+
theme(plot.title = element_text(face = "bold", size = 12, colour = "blue"))+
theme(axis.title = element_text(size = 12, colour = "black"))
#Setup Graph 5
library(readr)
mine_class1 <- read_csv("C:/Users/jmhp2/OneDrive/Desktop/ggplot2_pretty/mine_classification_with_lidar.csv")
##
## -- Column specification --------------------------------------------------------
## cols(
## .default = col_double(),
## class = col_character()
## )
## i Use `spec()` for the full column specifications.
View(mine_class1)
attach(mine_class1)
#Graph 5
ggplot(mine_class1, aes(x = class, y = ndvi, fill = class))+
geom_boxplot()+
theme_classic()+
ggtitle("NDVI by Landcover Type")+
labs(x = "Landcover Type", y = "NDVI Value")+
scale_x_discrete(breaks = c("barren", "forest", "herb", "shrub", "water"), labels = c("Barren", "Forest", "Herb", "Woodlands", "Water"))+
theme(axis.title.x = element_text(size = 12, colour = "blue"))+
theme(axis.title.y = element_text(size = 12, colour = "blue"))+
theme(plot.title = element_text(face = "bold", size = 16, colour = "blue"))+
theme(axis.title = element_text(size = 14, colour = "blue"))+
theme(legend.position = "None")+
theme(panel.grid.major.y = element_line(colour = "grey40", linetype = "dashed"))
#Bonus Graph 6
ggplot(mine_class1, aes(x = class, y = ndvi, fill = class))+
geom_col()+
theme_classic()+
ggtitle("NDVI by Landcover Type")+
labs(x = "Landcover Type", y = "NDVI Value")+
scale_x_discrete(breaks = c("barren", "forest", "herb", "shrub", "water"), labels = c("Barren", "Forest", "Herb", "Woodlands", "Water"))+
theme(axis.title.x = element_text(size = 12, colour = "blue"))+
theme(axis.title.y = element_text(size = 12, colour = "blue"))+
theme(plot.title = element_text(face = "bold", size = 16, colour = "blue"))+
theme(axis.title = element_text(size = 14, colour = "blue"))+
theme(legend.position = "None")