From c2909d6254b5d182aaf029d7af51ffa14f884cda Mon Sep 17 00:00:00 2001
From: Layla Riemann <layla.riemann@ptb.de>
Date: Mon, 2 Aug 2021 09:40:17 +0000
Subject: [PATCH] help file3 for R-code

---
 design_fig_v2.r | 53 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)
 create mode 100644 design_fig_v2.r

diff --git a/design_fig_v2.r b/design_fig_v2.r
new file mode 100644
index 0000000..3f33bd5
--- /dev/null
+++ b/design_fig_v2.r
@@ -0,0 +1,53 @@
+#
+#  ...\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)
+
-- 
GitLab