#Code to create publication quality line graph for multiple groups.
#set up space
setwd("C:/1awinz/R_work/Loberg_22")
data=read.table("LPM_frequency_plot_sicb.txt", header=T)
attach(data)
names(data)
## [1] "Population" "Yr_SF" "L"
#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. Note the use of the group command in ggplot to separate lines by population
base1<-ggplot(data, aes(x=Yr_SF, y=L, group=Population)) + geom_point() +geom_line() + xlab("Years Since Founding") + ylab("Low Morph Relative Frequency") + theme_classic()
#Adding colors and shapes
base1 + geom_point(aes(shape=Population, color=Population, size=Population)) + scale_shape_manual(values=c("square", "triangle", "diamond")) + scale_color_manual(values=c("gray50", "black", "gray70"))+ scale_size_manual(values=c(3, 3, 4))
#Save the plot as a tiff file with 350 dpi
ggsave("lpm_plot.tiff", width= 20, height=10, units="cm", device="tiff", dpi=350)