[R] contour lines for levelplot

From: Jan Marius Hofert <m_hofert_at_web.de>
Date: Sun 12 Feb 2006 - 19:52:25 EST


I would like to add contour lines to a (trellis/lattice-) levelplot. Sure, there is the "contour=TRUE" argument, but this uses "cuts=..." (which is usually chosen very high for my plots. I guess cuts=99 is the best you can do (?)) for plotting the contour lines. Furthermore, I do not like the numbering of the contour lines this way. Therefore, I tried to add a standard contour plot. There are 2 problems to do this. First, as I would like to have the levelplot with a colorkey, the contour lines are plotted over the colorkey (see example code below). I could not fix this problem by changing the aspect argument of the levelplot call or by working with xlim and ylim in the contour plot function. Second, I am not sure if the contour lines added this way actually represent the points they should (e.g. does the contour line labeled with 0.5 really hit the points of this height?). So, is there a simple way of how to add the contour lines (of the contour function) to the levelplot this way? If not, is it possible to plot the levelplot with cuts=99 but only draw the contour lines (with the option "contour=TRUE" in the levelplot call) at specified points? Is it possible to tell the levelplot function (with cuts=99) to plot a specified number of contour lines
(say, only to plot 10 contour lines in the whole existing range of z-

Thank you very much in advance


example code:


x.2 <- 0.04*(0:25)
y.2 <- 0.04*(0:25)
z.1 <-x.1*y.1
z.2<- matrix(unlist(z.1),ncol=26,byrow=TRUE)
library(lattice) #for trellis-like graphical plots plot.new()

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 Sun Feb 12 19:55:59 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:42:27 EST