Skip to content

overlaying a contour line in a levelplot

2 messages · Jorge Ahumada, Deepayan Sarkar

#
Hello there,

I am creating a series of images using levelplot but I also want to  
overlay a contour for a particular value as reference. Here is the  
levelplot command for the image:

print(levelplot(d~x+y,data=t,cuts=20,scales=list(draw=F),xlab=NULL,ylab= 
NULL,col.regions=heat.colors(100)[100:1]),split=c(1,1,1,1),more=T)

and then to add the contour plot (I only want a contour at level 5):

print(levelplot(d~x+y,data=t,cuts=20,scales=list(draw=F),xlab=NULL,ylab= 
NULL,contour=T,at=c(0,5),reg=F,labels=F),split=c(1,1,1,1))

this shifts the contourline to the right of the levelplot. If I use  
region=T then it looks better but it is still shifted slighlthy, plus  
have an extrakey overlayed to the original key with different numbers  
on it.

If I draw the first plot, but only put one contourline on it, I loose  
all the other colors...Any ideas?

thanks,

Jorge
#
On Wednesday 20 April 2005 09:16, Jorge Ahumada wrote:
You are going about this all wrong. Here's the correct way (with 
different data since you haven't given us a reproducible example):

levelplot(volcano,
          panel = function(..., at, region = TRUE, contour = FALSE) {
              panel.levelplot(..., at = at,
                              region = region,
                              contour = contour)
              panel.levelplot(..., at = 140,
                              region = FALSE,
                              contour = TRUE)
          })

Deepayan