Heidemeier Dr, Joachim
2008-Nov-20 07:27 UTC
[R] Repost:lattice graphics -- legend color problems
Hello R-folks, I don't get the color of the legend in a lattice-plot right. I select a palette from RColorBrewer and use (with a col = mypalette argument) it in the barchart plot. The resulting graph shows the new palette in the graph, but uses the standard palette in the legend rectangles. Adding a col argument into auto.key uses the new palette with the legend text, but not in the rectangle fill. What am I missing? TIA Joachim ---------code --------- library("lattice") library("RColorBrewer") # palette ausw?hlen mypalette <- brewer.pal(7,"Accent") pathBarchartFGE <- function(selector,data,dimension = 2,title = NULL,p = mypalette) { # umwandeln f?r lattice Grafiken dfvar <- as.data.frame.table(data) names(dfvar) <- c("Zeitraum","FGG","Pfad","Fracht") dfsel <- subset(dfvar,dfvar$FGG %in% selector) barchart(Zeitraum ~ Fracht | FGG, layout = c(1,3), groups = Pfad, stack = TRUE , col = p, data = dfsel, xlab = "Eintr?ge (t/a)",auto.key = list(title = "Pfade",columns = 2,space = "bottom"),main = title) } ------------------------- -- Dr. Joachim Heidemeier c/o Umweltbundesamt FG II 2.2 Tel.: +49340 2103-2780 eMail: joachim.heidemeier at uba.de
Don't use col = p; use par.settings = simpleTheme(col = p) 2008/11/20 Heidemeier Dr, Joachim <joachim.heidemeier at uba.de>:> Hello R-folks, > > I don't get the color of the legend in a lattice-plot right. > I select a palette from RColorBrewer and use (with a col = mypalette argument) it in the barchart plot. > The resulting graph shows the new palette in the graph, but uses the standard palette in the legend rectangles. > Adding a col argument into auto.key uses the new palette > with the legend text, but not in the rectangle fill. > What am I missing? > > TIA > > Joachim > > ---------code --------- > > library("lattice") > library("RColorBrewer") > # palette ausw?hlen > mypalette <- brewer.pal(7,"Accent") > pathBarchartFGE <- function(selector,data,dimension = 2,title = NULL,p = mypalette) { > # umwandeln f?r lattice Grafiken > dfvar <- as.data.frame.table(data) > names(dfvar) <- c("Zeitraum","FGG","Pfad","Fracht") > dfsel <- subset(dfvar,dfvar$FGG %in% selector) > barchart(Zeitraum ~ Fracht | FGG, layout = c(1,3), groups = Pfad, stack = TRUE , col = p, > data = dfsel, xlab = "Eintr?ge (t/a)",auto.key = list(title = "Pfade",columns = 2,space = "bottom"),main = title) > } > ------------------------- > > > > > > -- > Dr. Joachim Heidemeier > c/o Umweltbundesamt FG II 2.2 > Tel.: +49340 2103-2780 > eMail: joachim.heidemeier at uba.de > > ______________________________________________ > R-help at 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. >-- Felix Andrews / ??? http://www.neurofractal.org/felix/ 3358 543D AAC6 22C2 D336 80D9 360B 72DD 3E4C F5D8