I have 2 contour plots that I want to put into a layout, but the classical par()
and layout()
are not working for me. Aditionaly, because the plots are in the same scale, I'd like to use a single horizontal label in the top of the layout.
x <- c(0,25,50,75,100)
y <- c(0,10,20)
z1 <- matrix(c(12,12,13,12,5,12,5,5,5,12,5,12,13,14,15), nrow = 5, ncol = 3, byrow = TRUE)
z2 <- matrix(c(1,1,10,1,1,6,7,8,9,10,11,12,13,14,15), nrow = 5, ncol = 3, byrow = TRUE)
A <- matrix(seq(0, 100, by = 25), nrow = 3, ncol = 5, byrow = TRUE) #As x
B <- matrix(seq(0,20, by = 10), nrow = 3, ncol = 5) #As y
layout(matrix(c(1,2), nrow = 2, ncol = 1))
filled.contour(x,y,z1, color=terrain.colors,#
levels = seq(0,15, by = 1),#
plot.axes = { axis(1); axis(2); points(A,B);#
contour(x,y,z1, level=6, label = "6 u", add=TRUE)},#
key.axes = axis(4, seq(0, 15, by = 3)))
filled.contour(x,y,z2, color=terrain.colors,#
levels = seq(0,15, by = 1), xlab = "Y label",#
plot.axes = { axis(1); axis(4);points(A,B);#
contour(x,y,z2, level=2, label = "2 u", add=TRUE)})
My desired result will be something like