zhijie zhang
2007-Oct-12 12:58 UTC
[R] Anybody has ever met the problem to add a legend to a figure generated by image()?
Dear friends, Anybody has ever met the problem to add a legend to a figure generated by image()? I have three variables,x,y and z. x and y are the coordinates, and z is the third values. we can use image(x, y, z,...) to generate a figure according to the z-values, but the problem is the figure legend. How can the legend be added to a figure generated by image()? Note that filled.contour() can add the figure legend automatically, but there are some problems sometime. I want to know the specific method for adding the legend to the figure generated by image(). Thanks very much. ---------------------- 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:epistat@gmail.com Website: www.statABC.com [***********************************************************************] oooO::::::::: (..)::::::::: :\.(:::Oooo:: ::\_)::(..):: :::::::)./::: ::::::(_/:::: ::::::::::::: [[alternative HTML version deleted]]
Katharine Mullen
2007-Oct-12 13:05 UTC
[R] Anybody has ever met the problem to add a legend to a figure generated by image()
have you tried the function image.plot in the package fields? On Fri, 12 Oct 2007, zhijie zhang wrote:> Dear friends, > Anybody has ever met the problem to add a legend to a figure generated by > image()? I have three variables,x,y and z. > x and y are the coordinates, and z is the third values. we can use image(x, > y, z,...) to generate a figure according to the z-values, but the problem is > the figure legend. How can the legend be added to a figure generated > by image()? Note that filled.contour() can add the figure legend > automatically, but there are some problems sometime. I want to know the > specific method for adding the legend to the figure generated by image(). > Thanks very much. > > ---------------------- > 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:epistat at gmail.com > Website: www.statABC.com > [***********************************************************************] > oooO::::::::: > (..)::::::::: > :\.(:::Oooo:: > ::\_)::(..):: > :::::::)./::: > ::::::(_/:::: > ::::::::::::: > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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. >
Bert Gunter
2007-Oct-12 15:30 UTC
[R] Anybody has ever met the problem to add a legend to a figure generated by image()
?levelplot() is the standard lattice package version of image and automatically generates a legend. Note: if the image is expressed as a matrix, X, of nrow x ncol values, then (as in image()) then levelplot should be invoked with: rowindx <- seq.int(nrow(X)) levelplot(t(X)[,rev(rowindx)],scales=list(y=list(labels=rev(rowindx),at=rowi ndx)),xlab="Column", ylab="Row") to produce the image in correct orientation. Bert Gunter Genentech Nonclinical Statistics -----Original Message----- From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On Behalf Of Katharine Mullen Sent: Friday, October 12, 2007 6:05 AM To: zhijie zhang Cc: R-help at stat.math.ethz.ch Subject: Re: [R] Anybody has ever met the problem to add a legend to a figure generated by image() have you tried the function image.plot in the package fields? On Fri, 12 Oct 2007, zhijie zhang wrote:> Dear friends, > Anybody has ever met the problem to add a legend to a figure generatedby> image()? I have three variables,x,y and z. > x and y are the coordinates, and z is the third values. we can useimage(x,> y, z,...) to generate a figure according to the z-values, but the problemis> the figure legend. How can the legend be added to a figure generated > by image()? Note that filled.contour() can add the figure legend > automatically, but there are some problems sometime. I want to know the > specific method for adding the legend to the figure generated by image(). > Thanks very much. > > ---------------------- > 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:epistat at gmail.com > Website: www.statABC.com > [***********************************************************************] > oooO::::::::: > (..)::::::::: > :\.(:::Oooo:: > ::\_)::(..):: > :::::::)./::: > ::::::(_/:::: > ::::::::::::: > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guidehttp://www.R-project.org/posting-guide.html> and provide commented, minimal, self-contained, reproducible code. >______________________________________________ R-help at 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.
hadley wickham
2007-Oct-12 15:43 UTC
[R] Anybody has ever met the problem to add a legend to a figure generated by image()
On 10/12/07, Bert Gunter <gunter.berton at gene.com> wrote:> ?levelplot() is the standard lattice package version of image and > automatically generates a legend. > > Note: if the image is expressed as a matrix, X, of nrow x ncol values, then > (as in image()) then levelplot should be invoked with: > > rowindx <- seq.int(nrow(X)) > levelplot(t(X)[,rev(rowindx)],scales=list(y=list(labels=rev(rowindx),at=rowi > ndx)),xlab="Column", ylab="Row")Or (I think) library(reshape) levelplot(value ~ X1 * X2, melt(X)) And with ggplot2 library(ggplot2) qplot(X1, X2, fill=value, data=melt(z), geom="tile") Hadley -- http://had.co.nz/
Apparently Analagous Threads
- Generating series of distributions with the same skewness and different kurtosis or with same kurtosis and different skewness?
- handle dates in R?
- Specify a correct formula in R for Piecewise Linear Functions?
- How to add legend for image()?
- Is there any good tools to facilitate us to create R functions?