[R] Anybody has ever met the problem to add a legend to a figure generated by image()

Bert Gunter gunter.berton at gene.com
Fri Oct 12 17:30:46 CEST 2007


?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 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.
>

______________________________________________
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.



More information about the R-help mailing list