How can I change the color of the header in a xyplot?

前端 未结 1 842
忘掉有多难
忘掉有多难 2021-02-08 17:29

I am using xyplot from the lattice package, and I want to change the color of hte header. Currently, it is an ugly light-orange color.

library(lattice)

x <-          


        
1条回答
  •  难免孤独
    2021-02-08 17:35

    You need to reset the contents of trellis.par.get()$strip.background$col.

    To do this for a single plot, use the par.settings= argument:

    xyplot(y ~ x | a, groups = z < 5, data = DF, col = c("black", "red"),
           pch = 20, cex = 0.3, 
           par.settings = list(strip.background=list(col="lightgrey")))
    

    To more persistently reset the strip background color, use trellis.par.set():

    trellis.par.set(strip.background=list(col="lightgrey"))
    

    To see how you might have found this out yourself, try the following:

    names(trellis.par.get())
    trellis.par.get("strip.background")
    

    Finally, for an example of more complicated (and aesthetically appalling) strip-background manipulations, see here.

    0 讨论(0)
提交回复
热议问题