[R] Help with levelplot color assignment in lattice

sguyader sguyader at gmail.com
Mon Aug 29 15:20:01 CEST 2011


In fact by fiddling with the "at" and "colorkey" options, I was able to get
the result I expected. Now the colors are assigned correctly, as well as the
colorkey. Here's my code:

# see data in the original

data$level[is.na(data$level)] <- 10 # assign a value above the scale to NA
values

levelplot(level~ x* y, data = data, as.table=T,
             col.regions=c("#FFFFFF", "#FFFFC6", "#FFFF8D", "#FFFF55",
"#FFFF1C", "#FFE200", "#FFAA00", "#FF7100", "#FF3800", "#FF0000",
"#000000"),  # 10 colors from white to red through yellow for levels 0 to 9,
plus black for level=10
             at=c(-0.5:10.5),  # this is how I got colors centered on
integer values
             colorkey = list(at = c(-0.5:10.5),
labels=list(at=c(0:10),lab=c(as.character(c(0:9)),"NA"))),
             xlab="x", ylab="y", strip = strip.custom(factor.levels=c("date
3")))

I hope this can help somebody else in the future.

-Sebastien

--
View this message in context: http://r.789695.n4.nabble.com/Help-with-levelplot-color-assignment-in-lattice-tp3774374p3776206.html
Sent from the R help mailing list archive at Nabble.com.



More information about the R-help mailing list