# This code creates four histograms showing saccadic reaction time # data. The data is the same in each histogram, but histograms 1-3 # have different bin sizes, while histogram 4 has the same bin size # as histogram 3, but uses shifted bins. # # Figure caption: Four histograms of saccadic reaction time data. # The same data are used in each histogram. The appearance of the # data distribution depends on details of histogram creation. The # first three histograms have different bin sizes. The fourth # histogram uses the same bin size as the third, but shifts the # bin locations slightly. patient1 <- read.table("data/p3359b.csv")[[1]] # First we set up the histogram bin locations for all four histograms. binsMat <- matrix(c(0, 0.1, 1, 0, 0.02, 1, 0.0, 0.04, 1.0, 0.02, 0.04, 1.02), nrow = 4, byrow = TRUE) # We'll also need different y limits and y tickmarks for each # histogram. yLimitsMat <- matrix(c(0, 65, 0, 20, 0, 39, 0, 39), nrow = 4, byrow = TRUE) yTickMarksMat <- matrix(c(0, 20, 60, 0, 5, 20, 0, 10, 30, 0, 10, 30), nrow = 4, byrow = TRUE) # We loop here so we can choose graphical parameters once, and not # set them repeatedly for each histogram. dev.new(width = 10, height = 8) par(mfrow = c(2, 2)) par(mar = c(5, 4, 1, 1)) for(i in 1:4){ hist(patient1, breaks = seq(from = binsMat[i, 1], to = binsMat[i, 3], by = binsMat[i, 2]), xlab = "Time (s)", ylab = "", main = "", yaxt = "n", ylim = c(yLimitsMat[i, 1], yLimitsMat[i, 2]), cex.lab = 1.6, cex.axis = 1.5) axis(2, at = seq(from = yTickMarksMat[i, 1], to = yTickMarksMat[i, 3], by = yTickMarksMat[i, 2]), labels = seq(from = yTickMarksMat[i, 1], to = yTickMarksMat[i, 3], by = yTickMarksMat[i, 2]), cex.axis = 1.5) }