Skip to content

Commit 1f7d479

Browse files
authored
Update 03_Giling_et_al_motif_analysis_Supplementary.R
Tweak to colours for better colour-blind accessibility
1 parent 5f629fd commit 1f7d479

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

03_Giling_et_al_motif_analysis_Supplementary.R

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,15 +171,13 @@ plot.prop <- function(ytext, yaxt=TRUE, xaxt=TRUE) {
171171
return(results)
172172
}
173173

174-
# print figure and results
174+
# run analysis and print figure
175175
par(mfrow=c(1,4), oma=c(3,3,1,0), mar=c(1,1,2,1))
176176
results <- plot.prop("Detritivores", TRUE, TRUE)
177177
results <- plot.prop("Herbivores", FALSE, TRUE)
178178
results <- plot.prop("Omnivores", FALSE, TRUE)
179179
results <- plot.prop("Predators", FALSE, TRUE)
180180

181-
write.csv(results, "cons_prop_results.csv")
182-
183181

184182

185183
# 5. Supplemental Text 2: Habitat complexity scenario
@@ -190,7 +188,7 @@ write.csv(results, "cons_prop_results.csv")
190188
comp <- filter(comp, alpha==10000 & beta==10000)
191189

192190
# setup
193-
col.list <- c(rgb(62,150,81,max=255), rgb(57,106,177,max=255), rgb(218,124,48,max=255), rgb(204,37,41,max=255), "grey50")
191+
col.list <- c(rgb(0,158,115,max=255), rgb(0,114,178,max=255), rgb(230,159,0,max=255), rgb(204,121,167,max=255), "grey50")
194192

195193
# dataframe for predicting
196194
divseq <- seq(min(full$log2.psr), max(full$log2.psr), length.out = 100)
@@ -205,12 +203,12 @@ plot.zscores <- function(y, yaxt=TRUE, xaxt=TRUE, col=1) {
205203
plot(y ~ log2.psr, type='n', data=comp, ylim=c(-0.8,0.8), xlim=(c(0,6)),
206204
xaxt='n', yaxt='n', las=2, ylab = NA, xlab = NA)
207205
abline(h=0, lty=2)
208-
if(xaxt==TRUE)axis(1, at=log2(c(1,2,4,8,16,60)), lab=c(1,2,4,8,16,60))
206+
if(xaxt==TRUE)axis(1, at=log2(c(1,2,4,8,16,60)), lab=c(1,2,4,8,16,60), cex.axis=0.8)
209207
if(xaxt==FALSE)axis(1, at=log2(c(1,2,4,8,16,60)), lab=NA)
210-
if(yaxt==TRUE) axis(2, at=seq(-0.8,0.8,0.4), las=1)
208+
if(yaxt==TRUE) axis(2, at=seq(-0.8,0.8,0.4), las=1, cex.axis=0.8)
211209
if(yaxt==FALSE) axis(2, at=seq(-0.8,0.8,0.4), lab=NA, las=1)
212210

213-
points(y ~ log2.psr, data=comp, pch=16, col=add.alpha(col.list[col],0.1))
211+
points(y ~ log2.psr, data=comp, pch=16, col=add.alpha(col.list[col],0.15))
214212
lmm <- NULL
215213
lmm <-lmer(y ~ log2.psr + (1|block/plot) + (1|time.period), data=comp)
216214
#plot(lmm)
@@ -222,14 +220,13 @@ plot.zscores <- function(y, yaxt=TRUE, xaxt=TRUE, col=1) {
222220
return(results)
223221
}
224222

225-
# print figure and results
223+
# run analysis and print figure
226224
par(mfrow=c(2,2), oma=c(2,2,1,0), mar=c(1,1,2,1))
227225
results <- plot.zscores("s1.z.mean", TRUE, FALSE, 1)
228226
results <- plot.zscores("s2.z.mean", FALSE, FALSE, 2)
229227
results <- plot.zscores("s4.z.mean", TRUE, TRUE, 3)
230228
results <- plot.zscores("s5.z.mean", FALSE, TRUE, 4)
231229

232-
write.csv(results, "complexity_results.csv")
233230

234231

235232

0 commit comments

Comments
 (0)