[R] dotted contour line for negative values?

Ross Ihaka ihaka at stat.auckland.ac.nz
Tue May 11 03:32:45 CEST 1999


On Mon, 10 May 1999, Bill Simpson wrote:

> I have a contour plot where the surface can take on positive and negative
> values.  I would like to use solid contour lines for positive values and
> dotted contour lines for negative values. I saw a plot like this produced
> by S-Plus before.  Is there a way to do this with R? If not, can anyone
> suggest a way to make interpretation of the contour plot easier? (Right
> now, it is not clear if a set of "tree rings" in a plot indicate the
> presence of a peak or a trough)
> 
> I am thinking that it might be possible by making one plot of the positive
> contours with lty="solid", add=TRUE, then superimpose the negative
> contours with lty="dotted". The snag is: how to get only the positive or
> negative contours?

Here is a small example.  The trick is to specify the levels
and to use the add= argument.

	x <- seq(-1, 1, length=21)
	f <- function(x,y) (x^2 + y^2) / 2 - 0.5
	z <- outer(x, x, f)
	contour(z, levels = seq(-0.5, -0.1, by = 0.1), lty = "dotted")
	contour(z, levels = 0, lty = "dashed", add = TRUE)
	contour(z, levels = seq(0.1, 1, by = 0.1), add = TRUE)

Ross

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list