[R] Trellis stacked bar legend
deepayan.sarkar at gmail.com
Wed Mar 8 16:58:30 CET 2006
On 3/8/06, Dieter Menne <dieter.menne at menne-biomed.de> wrote:
> Dear R-Listers,
> (well... called Depayan)
> The standard example
> barchart(yield ~ variety | site, data = barley,
> groups = year, layout = c(1,6), stack = TRUE,
> auto.key = list(points = FALSE, rectangles = TRUE, space = "right"),
> ylab = "Barley Yield (bushels/acre)",
> scales = list(x = list(rot = 45)))
> shows the problem: legend colors are inverted compared to stack colors.
> This is still acceptable with 2 colors, but with 3 or more, people
> ask me why it's partly down-under. I use to mumble that one
> author is in New Zealand, the other either in India or in Wisconsin.
Blame René Descartes for making the positive y-axis point up. Writing
systems are pretty much universally top to bottom, as far as I know.
> I know the hard way to correct this, but auto.key is nice because
> it's print-time settings dynamic. Any easy workaround?
None I can think of, except circumventing Descartes with an additional
ylim = c(130, -5)
I was thinking of adding an option to panel.barchart, but a more
general solution would be options to flip the order in draw.key. I'll
see if that's doable.
More information about the R-help