#Code to create publication quality scatter plots.
#set up space
setwd("C:/1awinz/R_work/Loberg_22")
data=read.table("1_GR.txt", header=T)
attach(data)
names(data)
## [1] "GR"         "Year"       "Population" "Popcd"
#load tidyverse package
library(tidyverse)
## Warning: package 'tidyverse' was built under R version 4.1.2
## -- Attaching packages --------------------------------------- tidyverse 1.3.1 --
## v ggplot2 3.3.5     v purrr   0.3.4
## v tibble  3.1.4     v dplyr   1.0.7
## v tidyr   1.1.4     v stringr 1.4.0
## v readr   2.1.1     v forcats 0.5.1
## Warning: package 'tidyr' was built under R version 4.1.2
## Warning: package 'readr' was built under R version 4.1.2
## Warning: package 'forcats' was built under R version 4.1.2
## -- Conflicts ------------------------------------------ tidyverse_conflicts() --
## x dplyr::filter() masks stats::filter()
## x dplyr::lag()    masks stats::lag()
#Create base plot
base1<-ggplot(data, aes(x=Year, y=GR)) + geom_point() + xlab("Years Since Founding") + ylab("Mean Gillraker Number") + theme_classic()

#Adding colors and shapes
base1 + geom_point(aes(shape=Population, color=Population, size=Population)) + scale_shape_manual(values=c("square", "triangle", "triangle", "circle", "diamond")) + scale_color_manual(values=c("gray50", "black", "gray", "black", "gray70"))+ scale_size_manual(values=c(3, 3, 3, 3, 4)) 

#Save the plot as a tiff file with 350 dpi
ggsave("gr_plot.tiff", width= 20, height=10, units="cm", device="tiff", dpi=350)