[R] lattice package: Changing colors in graphs

Ravi Kulkarni ravi.kulk at gmail.com
Thu Feb 25 04:57:15 CET 2010


Giving different colors to plots of different levels of a factor can
be pleasing. For a boxplot, for example, the following produces a nice
plot:

boxplot(len~supp*dose, data=ToothGrowth, col=c(“orange”,”gray”))

 If I try to specify (using the lattice package)

histogram(~len|supp*factor(dose), data=ToothGrowth, col=c("orange","gray"))

 the effect is unexpected! (and certainly not desirable)

How does one do the same with histograms using the lattice package?
Also, how do I get more control over the colors of the "title bars"
for each pane in the lattice of graphs using the lattice package?

Ravi



More information about the R-help mailing list