The following is the example I work on.
require(lattice)
data(barley)
xyplot(yield ~ year | site, data = barley)

I want to put different strip color for different sprips and font color is also different optimized with the backgroud color. For example:
strip background colors = c("black", "green4", "blue", "red", "purple", "yellow")
font color = c("white", "yellow", "white", "white", "green", "red")
Rough sketch of the first one is provided:

How can I achieve this?
Here’s a clean and easily customizable solution.
myStripStyle(), the function that is passed in to thestrip=argument ofxyplot()uses the counter variablewhich.panelto select colors and also the value offactor.levelsfor the panel that’s currently being plotted.If you want to play around with the settings, just put a
browser()somewhere inside the definition ofmyStripStyle()and have at it!