Skip to content
Snippets Groups Projects
Commit c2909d62 authored by Layla Riemann's avatar Layla Riemann
Browse files

help file3 for R-code

parent 3df915a3
No related branches found
No related tags found
No related merge requests found
#
# ...\MRI_performance\2020-10-16_LR\R\design_fig_v1.r
#
# rm(list=ls())
## @knitr designfig
y <- list(rep=1, pos=2, sess=3, subj=4)
reps <- data.frame(x=c(1,3,5,7), y=rep(y$rep, 4), labels=c("1", "2", "1", "2"))
pos <- data.frame(x=c(1,3,6), y=rep(y$pos, 3), labels=c("A", "B", "C"))
sess <- data.frame(x=c(2, 6), y=rep(y$sess,2), labels=paste(1:2))
subj <- data.frame(x=4, y=y$subj, labels="Subject")
coords <- rbind(reps, pos, sess, subj)[1:2]
#Vertical line end locations [above label levels]
lo <- 0.2
hi <- 0.8
branch.lo <- 0.4
branch.hi <- 0.6
# Line width
lw <- 2
#Labels and label size
left.labels <- c("Replicate:", "Position:", "Session:")
l.cex <- 1.2
graphics.off()
windows(5, 3)
par(mar=c(2,6,1,1))
plot(coords, type='n', ann=FALSE, axes=FALSE, xlim=c(0.5, max(coords$x)))
segments(reps$x, reps$y+lo, reps$x, reps$y+branch.lo, lwd=lw)
segments(reps$x, reps$y+branch.lo, c(pos$x[1:2], rep(pos$x[3],2)), rep(y$rep+branch.hi, 4), lwd=lw)
segments(pos$x, pos$y-(1-branch.hi), pos$x, pos$y-(1-hi), lwd=lw)
segments(pos$x, pos$y+lo, pos$x, pos$y+branch.lo, lwd=lw)
segments(pos$x, pos$y+branch.lo, c(rep(sess$x[1], 2), sess$x[2]), rep(y$pos+branch.hi, 3), lwd=lw)
segments(sess$x, sess$y-(1-branch.hi), sess$x, sess$y-(1-hi), lwd=lw)
segments(sess$x, sess$y+lo, sess$x, sess$y+branch.lo, lwd=lw)
segments(sess$x, sess$y+branch.lo, rep(subj$x[1], 2), rep(y$sess+branch.hi, 2), lwd=lw)
segments(subj$x, subj$y-(1-branch.hi), subj$x, subj$y-(1-hi), lwd=lw)
with(reps, text(x, y, labels, cex=l.cex))
with(pos, text(x, y, labels, cex=l.cex))
with(sess, text(x, y, labels, cex=l.cex))
with(subj, text(x, y, labels, cex=l.cex))
axis(2, at=1:3, labels=left.labels,
las=2, cex.axis=l.cex, tick=FALSE)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment