我想用更粗的线条来画这个盒子。在boxplot函数中,我简单地放入了lwd=2,但在晶格bwplot中,我可以拔出头发,但还没有找到解决方案!

(我指的是上图中的蓝色盒子)
要使用的示例代码:
require(lattice)
set.seed(123)
n <- 300
type <- sample(c("city", "river", "village"), n, replace = TRUE)
month <- sample(c("may", "june"), n, replace = TRUE)
x <- rnorm(n)
df <- data.frame(x, type, month)
bwplot(x ~ type|month, data = df, panel=function(...) {
panel.abline(h=0, col="green")
panel.bwplot(...)
})发布于 2013-09-18 01:38:41
正如John Paul所指出的,线宽是由网格的图形参数列表的box.rectangle和box.umbrella组件控制的。(为了便于将来参考,键入names(trellis.par.get())是扫描由该列表控制的图形属性列表的一种快速方法。)
以下是为一个或多个特定数字设置这些选项的一种稍微简洁的方法:
thickBoxSettings <- list(box.rectangle=list(lwd=2), box.umbrella=list(lwd=2))
bwplot(x ~ type|month, data = df,
par.settings = thickBoxSettings,
panel = function(...) {
panel.abline(h=0, col="green")
panel.bwplot(...)
})

发布于 2013-09-18 01:22:40
您可以做的一件事是获取长方体的网格设置,然后更改这些设置。试一试
rect.settings<-trellis.par.get("box.rectangle") #gets all rectangle settings
rect.settings$lwd<-4 #sets width to 4, you can choose what you like
trellis.par.set("box.rectangle",rect.settings)把这些放在你的bwplot调用上面,它应该能做到。
框矩形设置也有颜色、填充等。
编辑以添加如果你得到box.umbrella,你可以编辑它来改变框上面和下面的线看起来像什么。
发布于 2013-09-18 01:47:05
值得一提的是,格子图还有一个更深层次的特性。它们实际上是对象,所以存在用于修改它们的列表表示的方法;
myBW <- bwplot(x ~ type|month, data = df, panel=function(...) {
panel.abline(h=0, col="green")
panel.bwplot(...)
})
newBW <- update(myBW, par.settings=list(box.rectangle=list(lwd=4) ))
plot(newBW) # need to print or plot a grid object您也可以使用trellis.focus并应用进一步的更新功能来覆盖新的数据或文本。
https://stackoverflow.com/questions/18855637
复制相似问题