Re: [R] How to add legend for image()?
zhijie zhang wrote: Dear friends, The following is an example to explain my question. I want to get a legend which will show the z-values according to different colors in image() function. x-sort(runif(10)) #x-coordinates y-sort(runif(10)) #y-coordinates z-matrix(runif(100),nrow=10) #attributes values image(x,y,z,col=gray((6:3)/6)) # legend(x,y,legend=z,col=gray((6:3)/6)) #error. the colors should denote different z-values, i want to get this legend. Hi Zhijie, Have a look at color.legend and color.scale in the plotrix package. 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.
[R] How to add legend for image()?
Dear friends, The following is an example to explain my question. I want to get a legend which will show the z-values according to different colors in image() function. x-sort(runif(10)) #x-coordinates y-sort(runif(10)) #y-coordinates z-matrix(runif(100),nrow=10) #attributes values image(x,y,z,col=gray((6:3)/6)) # legend(x,y,legend=z,col=gray((6:3)/6)) #error. the colors should denote different z-values, i want to get this legend. Thanks. -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 Dept. of Epidemiology,School of Public Health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 Email:[EMAIL PROTECTED] Website: www.statABC.com [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [[alternative HTML version deleted]] __ 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.
Re: [R] How to add legend for image()?
Have you tried filled.contour()? It automatically generates a legend. However, I'm not sure what is going on with your x's and y's being sorted random numbers. I assume your actual data are not like this. If you do not have data in an equally spaced grid you may need to create one by some sort of interpolation (e.g. Kriging or inverse distance weighting). On 10/2/07, zhijie zhang [EMAIL PROTECTED] wrote: Dear friends, The following is an example to explain my question. I want to get a legend which will show the z-values according to different colors in image() function. x-sort(runif(10)) #x-coordinates y-sort(runif(10)) #y-coordinates z-matrix(runif(100),nrow=10) #attributes values image(x,y,z,col=gray((6:3)/6)) # legend(x,y,legend=z,col=gray((6:3)/6)) #error. the colors should denote different z-values, i want to get this legend. Thanks. -- With Kind Regards, oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [***] Zhi Jie,Zhang ,PHD Tel:86-21-54237149 Dept. of Epidemiology,School of Public Health,Fudan University Address:No. 138 Yi Xue Yuan Road,Shanghai,China Postcode:200032 Email:[EMAIL PROTECTED] Website: www.statABC.com [***] oooO: (..): :\.(:::Oooo:: ::\_)::(..):: :::)./::: ::(_/ : [[alternative HTML version deleted]] __ 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. __ 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.