TMS*_*TMS 4 plot r lattice bwplot
我希望用更粗的线条绘制框.在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(...)
})
Run Code Online (Sandbox Code Playgroud)
正如约翰·保罗指出,线宽被控制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(...)
})
Run Code Online (Sandbox Code Playgroud)

您可以做的一件事是获取框的网格设置,并更改它们。尝试
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)
Run Code Online (Sandbox Code Playgroud)
将这些放在您的 bwplot 调用之上,它应该可以做到。
框矩形设置还有颜色、填充等。
编辑以添加如果您box.umbrella可以编辑它以更改框上方和下方的行的外观。
| 归档时间: |
|
| 查看次数: |
1468 次 |
| 最近记录: |