gpt4 book ai didi

r lattice - bwplot 后水平 abline 的错误位置

转载 作者:行者123 更新时间:2023-12-02 04:54:17 24 4
gpt4 key购买 nike

我可以毫无问题地做到这一点:

boxplot(coef ~ habitat, data = res)
abline(h = 0, col = "green")

但是当我使用 lattice 时,水平线错位了:

bwplot(coef ~ habitat, data = res)
abline(h = 0, col = "green")

enter image description here

我尝试使用 panel.abline 代替,但这会将绿线放在图片的顶部。

最佳答案

使用面板功能;按照您希望添加部件的顺序对包含的功能进行排序;利用 ... 避免了解/管理面板功能的所有参数

bwplot(coef ~ habitat, data = res, panel=function(...) {
panel.abline(h=0, col="green")
panel.bwplot(...)
})

当有多个面板时,面板功能的概念更有意义,例如,

res = data.frame(coef=rnorm(99) + (-1):1, habitat=sample(letters[1:3], 99, TRUE),
grp=c("W", "X", "Y"))
bwplot(coef ~ habitat | grp, data = res, panel=function(x, y, ...) {
## green line at panel-median y value
panel.abline(h=median(y), col="green")
panel.bwplot(x, y, ...)
})

关于r lattice - bwplot 后水平 abline 的错误位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18274873/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com