Re: [R] overlaying a contour line in a levelplot

From: Deepayan Sarkar <deepayan_at_stat.wisc.edu>
Date: Thu 21 Apr 2005 - 01:13:01 EST

On Wednesday 20 April 2005 09:16, Jorge Ahumada wrote:
> 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,yl
>ab= 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,yl
>ab= 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.

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



R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Thu Apr 21 01:20:02 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:31:17 EST