Skip to content
Prev 608 / 29559 Next

Adding maps to a filled contour plot

Hi,


Some time ago, Roger Peng posted this solution, which I found very useful:


junk.mat <- matrix(rnorm(1600), 16, 100)
contour.mat <- ifelse(junk.mat < 2, 0, junk.mat)
filled.contour(junk.mat, color = terrain.colors,
plot.axes = contour(contour.mat, levels = 1,
drawlabels = FALSE, axes = FALSE,
frame.plot = FFALSE, add = TRUE))


The 'plot.axes' argument to filled.contour() gives you access to the
coordinate system in the actual plotting area. However, you will notice
that the axes are missing. You need to add them explicitly, as in:


filled.contour(junk.mat, color = terrain.colors,
plot.axes = { contour(contour.mat, levels = 1,
drawlabels = FALSE, axes = FALSE,
frame.plot = FFALSE, add = TRUE);
axis(1); axis(2) } )



Cheers,


Antonio
--