[R] Legend placement in barplot?

Dan Bolser dmb at mrc-dunn.cam.ac.uk
Thu Nov 4 13:33:08 CET 2004

On Wed, 3 Nov 2004, Marc Schwartz wrote:

>On Wed, 2004-11-03 at 09:55, Dan Bolser wrote:
>> This has been asked before, but all the answers are hidiously complex.
>> The
>> legend.text=TRUE 
>> option of barplot is almost exactly what I need, except I need a
>> legend.placement='tl'
>> (top left) option. This option would be in contrast to the default
>> placement which we could call 'tr' (top right).
>> Anyone know how to edit the barplot code to make this change? Could
>> someone like me work out how to do this?
>> Cheers,
>> Dan.
>Do not edit the barplot() code. Use the legend() function instead, which
>enables you to specify the x,y coordinates of the upper left hand corner
>of the legend box. See ?legend

Thing is I need to pass legend the correct groups and correct plotting
colors and correct XY position relative to my data. All these things are
already known by the barplot function, and used to draw a beautiful

The fact that this legend can only appear in the upper right hand corner
is surly a bug worthy of changing the code for?

>A fair number of the questions that you have had regarding graphics are
>covered in Chapter 12 "Graphical Procedures" in "An Introduction to R":
>which is included with the R installation.
>Another online resource for some graphics assistance would be R News
>Volume 3 Number 2 for October 2003, which has an article on R's base
>graphics in the R Help Desk section:

Thanks for the links

>Notwithstanding all of that, searching the r-help archives is yet
>another terrific online (and free) resource that you _should_ avail
>yourself of.

Quoting me... "This has been asked before, but all the answers are
hidiously complex."

>Marc Schwartz

More information about the R-help mailing list