###################################################################################### data <- read.table("DENTAL_DISPARITY_DATA_2.txt", row.names=1, header=T) Kimmeridgian_data <- data[apply(data[3:12],1,function(x) any(x %in% "Kimmeridgian")),] Kimmeridgian_data Kimmeridgian_occurences <- table(unlist(Kimmeridgian_data[1:2])) Kimmeridgian_occurences Tithonian_data <- data[apply(data[3:12],1,function(x) any(x %in% "Tithonian")),] Tithonian_data Tithonian_occurences <- table(unlist(Tithonian_data[1:2])) Tithonian_occurences Berriasian_data <- data[apply(data[3:12],1,function(x) any(x %in% "Berriasian")),] Berriasian_data Berriasian_occurences <- table(unlist(Berriasian_data[1:2])) Berriasian_occurences Valanginian_data <- data[apply(data[3:12],1,function(x) any(x %in% "Valanginian")),] Valanginian_data Valanginian_occurences <- table(unlist(Valanginian_data[1:2])) Valanginian_occurences Hauterivian_data <- data[apply(data[3:12],1,function(x) any(x %in% "Hauterivian")),] Hauterivian_data Hauterivian_occurences <- table(unlist(Hauterivian_data[1:2])) Hauterivian_occurences Barremian_data <- data[apply(data[3:12],1,function(x) any(x %in% "Barremian")),] Barremian_data Barremian_occurences <- table(unlist(Barremian_data[1:2])) Barremian_occurences Aptian_data <- data[apply(data[3:12],1,function(x) any(x %in% "Aptian")),] Aptian_data Aptian_occurences <- table(unlist(Aptian_data[1:2])) Aptian_occurences Albian_data <- data[apply(data[3:12],1,function(x) any(x %in% "Albian")),] Albian_data Albian_occurences <- table(unlist(Albian_data[1:2])) Albian_occurences Cenomanian_data <- data[apply(data[3:12],1,function(x) any(x %in% "Cenomanian")),] Cenomanian_data Cenomanian_occurences <- table(unlist(Cenomanian_data[1:2])) Cenomanian_occurences Turonian_data <- data[apply(data[3:12],1,function(x) any(x %in% "Turonian")),] Turonian_data Turonian_occurences <- table(unlist(Turonian_data[1:2])) Turonian_occurences Coniacian_data <- data[apply(data[3:12],1,function(x) any(x %in% "Coniacian")),] Coniacian_data Coniacian_occurences <- table(unlist(Coniacian_data[1:2])) Coniacian_occurences Santonian_data <- data[apply(data[3:12],1,function(x) any(x %in% "Santonian")),] Santonian_data Santonian_occurences <- table(unlist(Santonian_data[1:2])) Santonian_occurences Campanian_data <- data[apply(data[3:12],1,function(x) any(x %in% "Campanian")),] Campanian_data Campanian_occurences <- table(unlist(Campanian_data[1:2])) Campanian_occurences Maastrichtian_data <- data[apply(data[3:12],1,function(x) any(x %in% "Maastrichtian")),] Maastrichtian_data Maastrichtian_occurences <- table(unlist(Maastrichtian_data[1:2])) Maastrichtian_occurences ###################################################################################### dental_time_series <- rbind(Kimmeridgian_occurences, Tithonian_occurences, Berriasian_occurences, Valanginian_occurences, Hauterivian_occurences, Barremian_occurences, Aptian_occurences, Albian_occurences, Cenomanian_occurences, Turonian_occurences, Coniacian_occurences, Santonian_occurences, Campanian_occurences, Maastrichtian_occurences) dental_time_series dental_time_series_proportions <- prop.table(dental_time_series, 1)*100 dental_time_series_proportions ####################################### bin_ranges <- read.table("bin_ranges.txt", header=T, row.names=1) midpoints <- rowMeans(bin_ranges) midpoints nbins <- length(midpoints) ngroups <- ncol(dental_time_series) x.limits <- c(max(bin_ranges), min(bin_ranges)) y.limits <- c(-max(dental_time_series_proportions), max(dental_time_series_proportions)) par(mfrow=c(8,1)) par(mar=c(0,0,0,0)) plot (bty="n", x.limits, y.limits, xlim = c(x.limits[1],x.limits[2]), col = "white", xlab = "", ylab = "", yaxt="n", xaxt="n") polygon (c(157.3, 152.1, 152.1, 157.3), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(145.0, 139.8, 139.8, 145.0), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(132.9, 129.4, 129.4, 132.9), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c( 125.0, 113.0,113.0, 125.0), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(100.5, 93.9, 93.9, 100.5), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(89.8, 86.3,86.3, 89.8), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(83.6, 72.1,72.1, 83.6), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) abline(v = c(145), col = "gray50", lwd = 1.3) # make gray background coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins ]) coordinates.y <- c(0, dental_time_series_proportions[, "1_CON"], 0) polygon (coordinates.x, coordinates.y, col = "gray60", border = NA) par(new=T) polygon (coordinates.x, -coordinates.y, col = "gray60", border = NA) plot (bty="n", x.limits, y.limits, xlim = c(x.limits[1],x.limits[2]), col = "white", xlab = "", ylab = "", yaxt="n", xaxt="n") polygon (c(157.3, 152.1, 152.1, 157.3), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(145.0, 139.8, 139.8, 145.0), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(132.9, 129.4, 129.4, 132.9), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(125.0, 113.0,113.0, 125.0), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(100.5, 93.9, 93.9, 100.5), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(89.8, 86.3,86.3, 89.8), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(83.6, 72.1,72.1, 83.6), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) abline(v = c(145), col = "gray50", lwd = 1.3) # make gray background coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins ]) coordinates.y <- c(0, dental_time_series_proportions[, "10_TRANS_BICUSP"], 0) polygon (coordinates.x, coordinates.y, col = "dodgerblue3", border = NA) par(new=T) polygon (coordinates.x, -coordinates.y, col = "dodgerblue3", border = NA) plot (bty="n", x.limits, y.limits, xlim = c(x.limits[1],x.limits[2]), col = "white", xlab = "", ylab = "", yaxt="n", xaxt="n") polygon (c(157.3, 152.1, 152.1, 157.3), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(145.0, 139.8, 139.8, 145.0), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(132.9, 129.4, 129.4, 132.9), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(125.0, 113.0,113.0, 125.0), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(100.5, 93.9, 93.9, 100.5), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(89.8, 86.3,86.3, 89.8), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(83.6, 72.1,72.1, 83.6), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) abline(v = c(145), col = "gray50", lwd = 1.3) # make gray background coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins]) coordinates.y <- c(0, dental_time_series_proportions[, "8_CUSPID_CON"], 0) polygon (coordinates.x, coordinates.y, col = "lightblue2", border = NA) par(new=T) polygon (coordinates.x, -coordinates.y, col = "lightblue2", border = NA) plot (bty="n", x.limits, y.limits, xlim = c(x.limits[1],x.limits[2]), col = "white", xlab = "", ylab = "", yaxt="n", xaxt="n") polygon (c(157.3, 152.1, 152.1, 157.3), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(145.0, 139.8, 139.8, 145.0), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(132.9, 129.4, 129.4, 132.9), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(125.0, 113.0,113.0, 125.0), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(100.5, 93.9, 93.9, 100.5), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(89.8, 86.3,86.3, 89.8), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(83.6, 72.1,72.1, 83.6), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) abline(v = c(145), col = "gray50", lwd = 1.3) # make gray background coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins]) coordinates.y <- c(0, dental_time_series_proportions[, "2_LEAF_CUSPS"], 0) polygon (coordinates.x, coordinates.y, col = "seagreen", border = NA) par(new=T) polygon (coordinates.x, -coordinates.y, col = "seagreen", border = NA) plot (bty="n", x.limits, y.limits, xlim = c(x.limits[1],x.limits[2]), col = "white", xlab = "", ylab = "", yaxt="n", xaxt="n") polygon (c(157.3, 152.1, 152.1, 157.3), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(145.0, 139.8, 139.8, 145.0), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(132.9, 129.4, 129.4, 132.9), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(125.0, 113.0,113.0, 125.0), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(100.5, 93.9, 93.9, 100.5), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(89.8, 86.3,86.3, 89.8), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(83.6, 72.1,72.1, 83.6), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) abline(v = c(145), col = "gray50", lwd = 1.3) # make gray background coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins]) coordinates.y <- c(0, dental_time_series_proportions[, "3_CRUSH"], 0) polygon (coordinates.x, coordinates.y, col = "salmon4", border = NA) par(new=T) polygon (coordinates.x, -coordinates.y, col = "salmon4", border = NA) plot (bty="n", x.limits, y.limits, xlim = c(x.limits[1],x.limits[2]), col = "white", xlab = "", ylab = "", yaxt="n", xaxt="n") polygon (c(157.3, 152.1, 152.1, 157.3), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(145.0, 139.8, 139.8, 145.0), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(132.9, 129.4, 129.4, 132.9), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(125.0, 113.0,113.0, 125.0), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(100.5, 93.9, 93.9, 100.5), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(89.8, 86.3,86.3, 89.8), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(83.6, 72.1,72.1, 83.6), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) abline(v = c(145), col = "gray50", lwd = 1.3) # make gray background coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins]) coordinates.y <- c(0, dental_time_series_proportions[, "4_COMP_RECURVE"], 0) polygon (coordinates.x, coordinates.y, col = "red3", border = NA) par(new=T) polygon (coordinates.x, -coordinates.y, col = "red3", border = NA) plot (bty="n", x.limits, y.limits, xlim = c(x.limits[1],x.limits[2]), col = "white", xlab = "", ylab = "", yaxt="n", xaxt="n") polygon (c(157.3, 152.1, 152.1, 157.3), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(145.0, 139.8, 139.8, 145.0), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(132.9, 129.4, 129.4, 132.9), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(125.0, 113.0,113.0, 125.0), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(100.5, 93.9, 93.9, 100.5), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(89.8, 86.3,86.3, 89.8), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(83.6, 72.1,72.1, 83.6), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) abline(v = c(145), col = "gray50", lwd = 1.3) # make gray background coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins]) coordinates.y <- c(0, dental_time_series_proportions[, "9_SHEAR_TRIAN"], 0) polygon (coordinates.x, coordinates.y, col = "sienna1", border = NA) par(new=T) polygon (coordinates.x, -coordinates.y, col = "sienna1", border = NA) plot (bty="n", x.limits, y.limits, xlim = c(x.limits[1],x.limits[2]), col = "white", xlab = "", ylab = "", yaxt="n", xaxt="n") polygon (c(157.3, 152.1, 152.1, 157.3), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(145.0, 139.8, 139.8, 145.0), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(132.9, 129.4, 129.4, 132.9), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(125.0, 113.0,113.0, 125.0), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(100.5, 93.9, 93.9, 100.5), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(89.8, 86.3,86.3, 89.8), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(83.6, 72.1,72.1, 83.6), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) abline(v = c(145), col = "gray50", lwd = 1.3) # make gray background coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins]) coordinates.y <- c(0, dental_time_series_proportions[, "5_HOOKED"], 0) polygon (coordinates.x, coordinates.y, col = "yellow3", border = NA) par(new=T) polygon (coordinates.x, -coordinates.y, col = "yellow3", border = NA) ########################## dev.copy(pdf,"TIME.pdf", width=4, height=6) dev.off() ###################################### # set up a plot region ###################################### gap <- 1 ## sometimes not needed y.limits <- c(0.01, .99) ## will leave tiny gaps at top and bottom - for aesthetics plot (x.limits, y.limits, xlim = c(x.limits[1],x.limits[2]), col = "white", xlab = "age (Ma)", ylab = "Relative diversity") ###################################### # Begin extracting data ###################################### relative.disparity = array (dim = c(nbins, ngroups)) # This creates an empty array of the proper proportions dental_time_series #the below script claculate the relative disparities/diversities ready for plotting for (i in 1:nrow(dental_time_series)) { relative.disparity [i, ] = c(dental_time_series[i, "1_CON"], dental_time_series[i, "4_COMP_RECURVE"], dental_time_series[i, "5_HOOKED"], dental_time_series[i, "9_SHEAR_TRIAN"], dental_time_series[i, "3_CRUSH"], dental_time_series[i, "8_CUSPID_CON"], dental_time_series[i, "10_TRANS_BICUSP"], dental_time_series[i, "2_LEAF_CUSPS"]) relative.disparity[i, ] = cumsum (relative.disparity [i, ]) relative.disparity [i, ] = relative.disparity [i, ]/relative.disparity [i, ngroups] } relative.disparity # polygon for 2_LEAF_CUSPS coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins ]) coordinates.y <- c(0, relative.disparity [, 8], 0) polygon (coordinates.x, coordinates.y, col = "seagreen", border = NA) # polygon for 10_TRANS_BICUSP coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins ]) coordinates.y <- c(0, relative.disparity [, 7], 0) polygon (coordinates.x, coordinates.y, col = "dodgerblue3", border = NA) #polygon for 8_CUSPID_CON coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins ]) coordinates.y <- c(0, relative.disparity [, 6], 0) polygon (coordinates.x, coordinates.y, col = "lightblue2", border = NA) #polygon for crush coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins ]) coordinates.y <- c(0, relative.disparity [, 5], 0) polygon (coordinates.x, coordinates.y, col="salmon4" , border = NA) #polygon for shear coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins ]) coordinates.y <- c(0, relative.disparity [, 4], 0) polygon (coordinates.x, coordinates.y, col = "sienna1", border = NA) #polygon for HOOKED coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins ]) coordinates.y <- c(0, relative.disparity [, 3], 0) polygon (coordinates.x, coordinates.y, col = "yellow3", border = NA) #polygon for recurved coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins ]) coordinates.y <- c(0, relative.disparity [, 2], 0) polygon (coordinates.x, coordinates.y, col = "red3", border = NA) #polygon for 1_CON coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins ]) coordinates.y <- c(0, relative.disparity [, 1], 0) polygon (coordinates.x, coordinates.y, col="gray60" , border = NA) par(new = TRUE) abline(v=lines_time, lwd=0.8, col=rgb(0, 0, 0, 0.2), lty=2) par(new = TRUE) plot(midpoints, data[,'Mean_Square_Eucl_D_centroid'], axes = FALSE, bty = "n", xlab = "", ylab = "", col = "transparent", xlim = x.limits, ylim = c(0,max(data[,'Mean_Square_Eucl_D_centroid'])*1.1)) axis(side=4, ylab = "Mean squared distance from centroid") lines (midpoints, data[,'Mean_Square_Eucl_D_centroid'], lty=1, lwd=1,col = "white") points (midpoints, data[,'Mean_Square_Eucl_D_centroid'], pch = 21, col = "black", bg = "white", cex=0.7) dev.copy(pdf,"Stacked_dental_plot.pdf", width=8, height=4.5) dev.off() dev.copy(pdf,"Squamate_Stacked_dental_plot.pdf", width=8, height=4.5) dev.off() dev.copy(pdf,"Squamate_Stacked_dental_plot.V2.pdf", width=5, height=5) dev.off() dev.copy(pdf,"Squamate_Stacked_dental_plot.times.pdf", width=8, height=4.5, family="Times") dev.off() dev.copy(pdf,"Squamate_Stacked_dental_plot.times.V2.pdf", width=5, height=5, family="Times") dev.off() ############################################################################ ############################################################################ ############################################################################ ############################################################################ ############################################################################ library(scales) data <- read.table ("PART_DISP_CLADES_DATA.txt", header = T) data bin_ranges <- read.table("bin_ranges.txt", header=T, row.names=1) midpoints <- rowMeans(bin_ranges) midpoints nbins <- length(midpoints) ngroups <- ncol(dental_time_series) x.limits <- c(max(bin_ranges), min(bin_ranges)) y.limits <- c(0,max(rowSums(dental_time_series)*1.05)) gap <- 1 ## sometimes not needed plot (x.limits, y.limits, xlim = c(x.limits[1],x.limits[2]), col = "white", xlab = "age (Ma)", ylab = "Relative diversity") polygon (c(157.3, 152.1, 152.1, 157.3), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(145.0, 139.8, 139.8, 145.0), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(132.9, 129.4, 129.4, 132.9), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c( 125.0, 113.0,113.0, 125.0), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(100.5, 93.9, 93.9, 100.5), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(89.8, 86.3,86.3, 89.8), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) polygon (c(83.6, 72.1,72.1, 83.6), y = c(-1000, -1000, 3000, 3000), border = NA, col = rgb (0, 0, 0, 0.06)) abline(v = c(145), col = "gray50", lwd = 1.3) # make gray background ###################################### # Begin extracting data ###################################### relative.disparity = array (dim = c(nbins, ngroups)) # This creates an empty array of the proper proportions dental_time_series #the below script claculate the relative disparities/diversities ready for plotting for (i in 1:nrow(dental_time_series)) { relative.disparity [i, ] = c(dental_time_series[i, "1_CON"], dental_time_series[i, "4_COMP_RECURVE"], dental_time_series[i, "5_HOOKED"], dental_time_series[i, "9_SHEAR_TRIAN"], dental_time_series[i, "3_CRUSH"], dental_time_series[i, "8_CUSPID_CON"], dental_time_series[i, "10_TRANS_BICUSP"], dental_time_series[i, "2_LEAF_CUSPS"]) } relative.disparity # polygon for 2_LEAF_CUSPS coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins ]) coordinates.y <- c(0, relative.disparity [, 1]+relative.disparity [, 2]+relative.disparity [, 3]+relative.disparity [, 4]+relative.disparity [, 5]+relative.disparity [, 6]+relative.disparity [, 7]+relative.disparity [, 8], 0) polygon (coordinates.x, coordinates.y, col = "seagreen", border = NA) # polygon for 10_TRANS_BICUSP coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins ]) coordinates.y <- c(0, relative.disparity [, 1]+relative.disparity [, 2]+relative.disparity [, 3]+relative.disparity [, 4]+relative.disparity [, 5]+relative.disparity [, 6]+relative.disparity [, 7], 0) polygon (coordinates.x, coordinates.y, col = "dodgerblue3", border = NA) #polygon for 8_CUSPID_CON coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins ]) coordinates.y <- c(0, relative.disparity [, 1]+relative.disparity [, 2]+relative.disparity [, 3]+relative.disparity [, 4]+relative.disparity [, 5]+relative.disparity [, 6], 0) polygon (coordinates.x, coordinates.y, col = "lightblue2", border = NA) #polygon for crush coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins ]) coordinates.y <- c(0, relative.disparity [, 1]+relative.disparity [, 2]+relative.disparity [, 3]+relative.disparity [, 4]+relative.disparity [, 5], 0) polygon (coordinates.x, coordinates.y, col="salmon4" , border = NA) #polygon for shear coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins ]) coordinates.y <- c(0, relative.disparity [, 1]+relative.disparity [, 2]+relative.disparity [, 3]+relative.disparity [, 4], 0) polygon (coordinates.x, coordinates.y, col = "sienna1", border = NA) #polygon for HOOKED coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins ]) coordinates.y <- c(0, relative.disparity [, 1]+relative.disparity [, 2]+relative.disparity [, 3], 0) polygon (coordinates.x, coordinates.y, col = "yellow3", border = NA) #polygon for recurved coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins ]) coordinates.y <- c(0, relative.disparity [, 1]+relative.disparity [, 2], 0) polygon (coordinates.x, coordinates.y, col = "red3", border = NA) #polygon for 1_CON coordinates.x <- c(midpoints[1], midpoints, midpoints [nbins ]) coordinates.y <- c(0, relative.disparity [, 1], 0) polygon (coordinates.x, coordinates.y, col="gray60" , border = NA) lines(midpoints, relative.disparity [, 1]+relative.disparity [, 2]+relative.disparity [, 3]+relative.disparity [, 4]+relative.disparity [, 5]+relative.disparity [, 6]+relative.disparity [, 7]+relative.disparity [, 8], lty=1, lwd=0.5,col = "white") lines(midpoints, relative.disparity [, 1]+relative.disparity [, 2]+relative.disparity [, 3]+relative.disparity [, 4]+relative.disparity [, 5]+relative.disparity [, 6]+relative.disparity [, 7], lty=1, lwd=0.5,col = "white") lines(midpoints, relative.disparity [, 1]+relative.disparity [, 2]+relative.disparity [, 3]+relative.disparity [, 4]+relative.disparity [, 5]+relative.disparity [, 6], lty=1, lwd=0.5,col = "white") lines(midpoints, relative.disparity [, 1]+relative.disparity [, 2]+relative.disparity [, 3]+relative.disparity [, 4]+relative.disparity [, 5], lty=1, lwd=0.5,col = "white") lines(midpoints, relative.disparity [, 1]+relative.disparity [, 2]+relative.disparity [, 3]+relative.disparity [, 4], lty=1, lwd=0.5,col = "white") lines(midpoints, relative.disparity [, 1]+relative.disparity [, 2]+relative.disparity [, 3], lty=1, lwd=0.5,col = "white") lines(midpoints, relative.disparity [, 1]+relative.disparity [, 2], lty=1, lwd=0.5,col = "white") lines(midpoints, relative.disparity [, 1], lty=1, lwd=0.5,col = "white") dev.copy(pdf,"Stacked_not_prop_dental_plot_v2.pdf", width=8, height=4.5) dev.off()