Hi All,

I have a question regarding re-ordering legend labels, I'm not sure if it
would be possible to do what I'm thinking...

Using the following code, I reordered labels for the legend:

Now in the stacked bars, we see 1931 values are plotted below 1932 whereas
in legend 1931 comes above 1932. So in the process if we look at stacked
bars, color "blue" is below "pink" whereas at the same time if one looks at
the legends its the other way around.

Is there way to re-order legends in a way that colors look in same order?

Code:
library(lattice)
barley$year <- factor(barley$year, levels=c(1931,1932))
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)))

Thanks alot,
Peng Cai

        [[alternative HTML version deleted]]

______________________________________________
R-help@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.

Reply via email to