options(scipen=999) library(ggplot2) library(reshape) setwd("") #SET YOUR WORKING DIRECTORY HERE AND PUT THE DATA CSV INTO THAT DIRECTORY WWWater <- rgb(85,155,185, max=255) WWAgriculture <- rgb(230,230,0, max=255) WWBarren <- rgb(225,225,225, max=255) WWForest <- rgb(190,217,190, max=255) WWGrassland<-rgb(230,215,130, max=255) WWForest <-rgb(190,217,190, max=255) WWDarkUmber <- rgb(115,0,0, max=255) WWDarkRoyalBlue <- rgb(0,77,204, max=255) BHPaleGreen <- rgb(227,235,229, max=255) WWPOS <- rgb(70,140,115, max=255) BHBackgroundColor = "Grey95" BHDarkerColor="Grey40" MyWedgeColors <- c("darkolivegreen", WWForest, BHPaleGreen,BHDarkerColor, WWAgriculture, WWDarkUmber, WWWater) #Import and Set Up Data For ggplot ReadInData <- read.csv("hf360-01-landcover-data.csv") #since the data as it is sums up to greater than 100, let's make unprotected forest simply 1 minus all others. ReadInData$Unprotected.Forest <- NULL # remove that column ReadInData$Remainder <- 1-(ReadInData[,2]+ReadInData[,3]+ReadInData[,4] +ReadInData[,5] +ReadInData[,6]+ReadInData[,7]) ReadInData <- ReadInData[c(1,2,3,8,4,5,6,7)] #reorder the columns so that they graph in the correct bottom to top order ReadInData <- ReadInData *100 #convert decimal percents to percents ReadInData$Year <- ReadInData$Year / 100 OrigData <-melt(ReadInData, id=c("Year")) OrigData$LULC <- OrigData$variable OrigData$variable <- NULL OrigData$Percent <- OrigData$value OrigData$value <-NULL #ReadInData <-NULL #Make Stacked linegraph attach(OrigData) pdf("Stacked Bar Graph TO BE NEATENED UP IN ILLUSTRATOR.pdf", width = 6, height = 2.75) ggplot(OrigData, aes(x=Year, y=OrigData$Percent, fill=LULC, ylab="Y")) + geom_area() + scale_fill_manual(values=MyWedgeColors) + #theme(legend.position=c(.30,.50)) + # theme_bw() + # theme(axis.line = element_line(colour = "white"), # panel.grid.major = element_blank(), # panel.grid.minor = element_blank(), # panel.border = element_blank(), # panel.background = element_blank())+ theme(legend.position="none") + theme(panel.background = element_rect( fill= "white")) + labs(y = "Percent of New England") + theme(axis.text = element_text(colour = "black"), axis.ticks = element_blank()) + scale_x_continuous(name="Year", breaks=c(1940,1960,1980,2000,2010,2060,2070), limits=c(1940,2070)) + annotate("rect", xmin=2010, xmax=2070, ymin=0, ymax=100, fill="white", alpha=0.00) + geom_vline(xintercept = 2010) + geom_vline(xintercept = 2060) + annotate("text", x = 2035, y = 2.5, label = "Wildlands") + annotate("text", x = 1975, y = 6, label = "Protected Forest") + annotate("text", x = 2005, y = 12, label = "X%") + annotate("text", x = 1975, y = 50, label = "Unprotected Forest") + annotate("text", x = 1975, y = 85, label = "Farmland") + annotate("text", x = 1975, y = 90, label = "Developed") + annotate("text", x = 1975, y = 95, label = "Water or Wetland") + annotate("text", x = 2012, y = 50, label = "Start of W&W Vision", angle = 90) + annotate("text", x = 2062, y = 50, label = "W&W Vision Accomplished", angle = 90) dev.off()