[R] legend outside axes of image or other plot

Roger Peng rpeng at stat.ucla.edu
Wed Sep 11 02:27:25 CEST 2002


You have two options that you more or less need to evaluate for yourself.
One is the 'image.plot' function in the 'fields' library.  This function
is useful and I've used it successfully a few times but you need to do
some careful calibration of the parameters to make the picture look good.
The other option is the 'filled.contour' function (in the base package)
which I think generally produces better pictures (but can be a lot
slower).  

I think both 'image.plot' and 'filled.contour' both split the plot device
into two separate regions (one for image and one for legend).  But
'filled.contour' uses kind of a hack-ish mechanism (via the plot.axes and
key.axes arguments) which gives you access to the coordinate systems of
the separate plot regions so that you can add text, labels, points, etc.  
This is really useful!  In general, I like 'filled.contour' better and try
to use it for these kinds of plots.

Unfortunately, 'filled.contour' uses 'layout' so cannot be used in
multiple panel displays.  'image.plot' can be used in such a situation.  

Hope this helps!

-roger
_______________________________
UCLA Department of Statistics
rpeng at stat.ucla.edu
http://www.stat.ucla.edu/~rpeng

On Tue, 10 Sep 2002, Richard Condit wrote:

> I have tried and tried unsuccessfully to place a legend outside the plot 
> frame of a graph. This would allow me to draw a legend for an image() plot. 
> But any legend I add is cut off outside the axes.
> 
> Is there a way of doing this? Thanks for any advice on how to make this 
> work (I'm using R1.5.1 with Windows 2000).
> 
> 
> Richard Condit
> Smithsonian Tropical Research Institute
> Unit 0948
> APO AA 34002-0948
> 
> condit at ctfs.si.edu
> conditctfs at yahoo.com
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 


-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list