簡體   English   中英

r格子-bwplot后水平垂直線的位置錯誤

[英]r lattice - wrong position of horizontal abline after bwplot

我可以做到這一點而沒有問題:

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

但是當我使用點陣時,水平線放錯了位置:

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

在此處輸入圖片說明

我嘗試使用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, ...)
})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM