On 09/16/2010 12:05 PM, rusers.sh wrote:
Hi all,
   I want to put several figures in a one figure for easy comparison, so i
need to use the same methods to plot these figures. The following is an
example. I also list my method, but it does not work.
#Example data
x<- 1:10; y<- 1:10; z<- outer( x,y,"+");z2<- outer( x,y,"-")
#Quick view them
image.plot(x,y,z)  #relatively larger value
image.plot(x,y,z2)   #relatively small value
#define the same breaks and colors
brks<-quantile(c(as.vector(z),as.vector(z2)),na.rm=TRUE)
colsn<-length(brks)-1
cols<-gray((colsn:1)/colsn)
#I expect they use the same breaks and colors
par(mfrow=c(1,2))
image.plot(x,y,z,breaks=brks,col=cols)
image.plot(x,y,z2,breaks=brks,col=cols)
par(mfrow=c(1,1))
   I think they really use the same breaks and colors, but you can see the
color legends are still different. One is 20-15-10-5, another is 5-0--5.
   I hope they not only use the same breaks and colors, but also display the
same color legends. How can i do it?

Hi Jane,
The color.legend function in the plotrix package will do this - see the examples, especially those for the "barp" function.

Jim

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to