




split.screen(c(1,2))
split.screen(c(2,1),1)

plot(1:5)

screen(2)
plot(1:10)
screen(4)
plot(10:1)

##################################3

close.screens(all.screens = TRUE)

split.screen(c(1,2))
split.screen(c(2,1), 1) ## split right side

i = 1

## plot the main effect for on y1 ##
for (i in 1:dim(main)[1]) {
        plot(x1, main[i,beg1:end1], ylim = c(min(main[,beg1:end1]), max(main[,beg1:end1])), type="l", col = i,
                xlab = "x1", ylab = "y1", main = "main effect on y1")
        par(new=TRUE)
}

screen(2)
plot(1:5, axes = FALSE, xlab = "", ylab = "")

legend(2,2,c("low","med", "high"), col = 1:3, lty=1)

screen(4)
# plot the main effect for on y2 ##
for (i in 1:dim(main)[1]) {
        plot(x2, main[i,beg2:end2], ylim = c(min(main[,beg2:end2]), max(main[,beg2:end2])), type="l", col = i,
                xlab = "x2", ylab = "y2", main = "main effect on y2")
        par(new=TRUE)
}













