library(readr) library(ggplot2) library(gridExtra) library(ggrepel) measurements <- read_csv("path/to/file/Suppl_File_2_measurements.csv", col_types = cols(head_pereon_length = col_number(), head_pereon_width = col_number(), pleon_telson_length = col_number(), pleon_telson_width = col_number())) df<-as.data.frame(measurements) df$rel_w <- (pmax(df$head_pereon_width,df$pleon_telson_width))/(df$head_pereon_length+df$pleon_telson_length) df$ant_post_l <- df$head_pereon_length/df$pleon_telson_length df$ant_post_w <- df$head_pereon_width/df$pleon_telson_width #ggplot(df, aes(y=rel_w, x = seq(1, length(df$rel_w)), color=taxon2, group=taxon2))+ #geom_point() df$colcon<-with(df, ifelse(age!="triassic",0,1)) df$colcon<-with(df, ifelse(age=="triassic",1,0)) ###not really the best combination of axes### #ggplot(df, aes(y=ant_post_w, x =rel_w , color=taxon2, group=taxon2))+ # geom_point(data = subset(df, colcon==0), size=2)+ # scale_x_log10()+ # scale_y_log10()+ # geom_text(aes(label=ifelse((age=="triassic"), species, '')), color="black", hjust=-0.05, vjust=-0.05)+ # scale_color_brewer(palette = "Paired")+ # geom_point(data = subset(df, colcon==1), color="black", size=2)+ # theme_bw() apw_apl <- ggplot(df, aes(y=ant_post_w, x =ant_post_l , color=taxon2, group=taxon2))+ geom_point(data = subset(df, colcon==0), size=2)+ scale_x_log10()+ scale_y_log10()+ geom_text_repel( aes(label=ifelse((age=="triassic"), species, '')), color="black", nudge_y = 0.2, box.padding = 1, point.padding = 0, segment.color = "grey", min.segment.length=0 )+ scale_color_brewer(palette = "Paired")+ geom_point(data = subset(df, colcon==1), color="black", size=2, shape=17)+ #geom_text(aes(label=ifelse((ant_post_l>10), species,'')))+ #determine the outliers #theme_bw()+ theme(legend.position="none")+ xlab("Length of the anterior body part relative to the length of the posterior body part")+ ylab("Width of anterior body part relative to the width of the posterior body part") apl_rw <- ggplot(df, aes(y=ant_post_l, x =rel_w , color=taxon2, group=taxon2))+ labs(color = "Systematic groups")+ geom_point(data = subset(df, colcon==0), size=2)+ scale_x_log10()+ scale_y_log10()+ geom_text_repel( aes(label=ifelse((age=="triassic"), species, '')), color="black", #nudge_x = -0.2, nudge_y = 0.2, box.padding = 1, point.padding = 0, segment.color = "grey", min.segment.length=0 )+ scale_color_brewer(palette = "Paired")+ geom_point(data = subset(df, colcon==1), color="black", size=2, shape=17)+ #geom_text(aes(label=ifelse((rel_w>10), species,'')))+ #determine the outliers #theme_bw()+ xlab("Relative width of the body")+ ylab("Length of the anterior body part relative to the length of the posterior body part")+ theme(legend.title=element_text(size=11), legend.text=element_text(size=11) ) grid.arrange(apw_apl,apl_rw, ncol=2)