Skip to content
Prev 26293 / 398502 Next

adding contour lines to a filled.contour

Andy Bunn wrote:
Yes. Look into the code of filled.contour(), how things are set up for
those two parts of the plot. The following solution will become clear:

 # your code:
 junk.mat <- matrix(rnorm(1600), 16, 100)
 filled.contour(junk.mat, color = terrain.colors)
 contour.mat <- ifelse(junk.mat < 2, 0, junk.mat)

 # insert 3 lines of code, stolen from filled.contour():
 mar.orig <- par("mar")
 w <- (3 + mar.orig[2]) * par("csi") * 2.54
 layout(matrix(c(2, 1), nc = 2), widths = c(1, lcm(w)))

 # your code:
 contour(contour.mat, levels = 1, drawlabels = FALSE, 
     axes = FALSE, frame.plot = FFALSE, add = TRUE)
 

Uwe Ligges