如何更改xyplot中标题的颜色? [英] How can I change the color of the header in a xyplot?

查看:74
本文介绍了如何更改xyplot中标题的颜色?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用来自点阵包的xyplot,并且我想更改hte标头的颜色.目前,它是一种难看的浅橙色.

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 <- c(1:10, 1:10)
y <- c(10:1, 10:1)
z <- c(1:10, seq(1,20, by=2))
a = c(rep("one",10),rep("two",10))
DF <- data.frame(x, y, z, a)
xyplot(y ~ x | a, groups = z < 5, data = DF, col = c("black", "red"),
 pch=20, cex=0.3)

推荐答案

您需要重置trellis.par.get()$strip.background$col的内容.

要对单个图执行此操作,请使用par.settings=参数:

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")))

要更持久地重置带状背景颜色,请使用trellis.par.set():

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.

这篇关于如何更改xyplot中标题的颜色?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆