Re: [R] Barchart legend position

From: Deepayan Sarkar <>
Date: Fri, 22 Jun 2007 14:25:09 -0700

On 6/22/07, Spilak,Jacqueline [Edm] <> wrote:
> I am using barchart to make charts for some data with a lot more
> functions and labels and such in the command.
> barchart(Freq ~ factor(HH), data = dataset1, group= year)
> So I have my data grouped by year and I get a legend at the top of
> graph, which is great cause I need the legend for the different years
> but it is a weird spot. So how can I manipulate the legend, ie. Move
> it, shrink it, do anything with it. I have searched the help archives
> and found nothing, and I have looked up the legend section in ?barchart
> but that has not helped or I am doing something wrong. Any help is
> greatly appreciated.

I can be more specific if you say what exactly you want to do (preferably with a small reproducible example). The relevant documentation is the part under 'key' in help(barchart). I prefer to use 'auto.key' instead (and you haven't told us what you are using), but most components of 'key' can be passed through 'auto.key'. Some examples:


         auto.key = list(space = "right", size = 2, cex = 0.5))


         auto.key = list(x = 0.75, y = 0.25, size = 2))

## choose location interactively:



         page = function(n) {
             cat("Click on plot to place legend", fill = TRUE)
             ll <- grid.locator(unit = "npc")
             if (!is.null(ll))
                                    rect = TRUE, points = FALSE),
                          vp = viewport(x = ll$x, y = ll$y),
                          draw = TRUE)

-Deepayan mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Fri 22 Jun 2007 - 21:42:17 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Fri 22 Jun 2007 - 22:32:30 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.