[R] Question about graphics in R

From: Martin Erwig <erwig_at_eecs.oregonstate.edu>
Date: Sun 08 Jan 2006 - 04:47:11 EST


Considering the R function/plot shown below, I wonder whether it is possible to do the following changes:

(1) Change the color of each point to be picked from
list of colors according to its z-value. (The range should be from blue (z=0) to red (z=1).) The grid should then be omitted. [I have seen "terrain.colors", but don't know how to use it for this purpose.]

(2) Add two lines to the surface for, say z=0.8 and
z=0.3. [Can contour or contourLines be used?]

---

x <- seq(0, 1, length = 50)
y <- x
f <- function(x,y) { sin ((1-x)*y) }
z <- outer(x,y,f)

persp(x, y, z,
	theta = 30, phi = 30,
	shade = 0.3, col = "red"
	)

---


Finally, I would also produce a flattened 2D map
of the same function, i.e. a map in which each point

(x,y) is mapped to a color in a range according to
f(x,y). Also two lines for f(x,y)=c1 and f(x,y)=c2 should be added. Is this possible? I would be grateful for any hints. Thanks, Martin ______________________________________________ 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 Jan 08 04:55:32 2006

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:41:57 EST