Hi All.

I have created two, 3-D, color graphs using persp(). Z values range from 1
to 100 on the first plot, and 0.5 to 50 on the second plot.
I would like to keep the color range constant between the two graphs, rather
than each graph showing the full range of colors.
So the first graph should go from yellow to red and the second graph should
go from yellow to orange.

Below I present a simplified version of my code which was taken from one of
the examples in persp(). In the code below I could simply type
colorRampPalette(c("yellow","orange")) for the second graph, but my actual
data is not this clean, so I am looking for a general solution to
keeping the colors consistent with z-values, rather than number of facets.

x <- 1:10
y <- 1:10
z1 <- matrix(1:100,10,10)
z2 <- matrix(seq(0.5,50,by=.5),10,10)

z <- z1

nrz <- nrow(z)
ncz <- ncol(z)
jet.colors <- colorRampPalette( c("yellow", "red") )
nbcol <- 100
color <- jet.colors(nbcol)
zfacet <- z[-1, -1] + z[-1, -ncz] + z[-nrz, -1] + z[-nrz, -ncz]
facetcol <- cut(zfacet, nbcol)

persp(x,y,z,col=color[facetcol], ticktype = "detailed", phi=30,theta=30)

##### Second Graph ###

z <- z2

nrz <- nrow(z)
ncz <- ncol(z)
jet.colors <- colorRampPalette( c("yellow", "red") )
nbcol <- 100
color <- jet.colors(nbcol)
zfacet <- z[-1, -1] + z[-1, -ncz] + z[-nrz, -1] + z[-nrz, -ncz]
facetcol <- cut(zfacet, nbcol)

persp(x,y,z,col=color[facetcol], ticktype = "detailed", phi=30,theta=30)

######

Thank you in advance for any advice.

Sincerely,
Tali Vardi, PhD Candidate
Scripps Institution of Oceanography
R 2.12.2 GUI 1.36 Leopard build 32-bit (5691)


--
View this message in context: http://r.789695.n4.nabble.com/keep-color-range-constant-across-three-persp-graphs-tp3387932p3387932.html
Sent from the R help mailing list archive at Nabble.com.
	[[alternative HTML version deleted]]

