我有以下代碼,允許通過函數在lattice
分組垂直方塊圖。重複的例子..與bwplot分組水平boxplot
data(mpg, package = "ggplot2")
bwplot(hwy~class, data = mpg, groups = year,
pch = "|", box.width = 1/3,
auto.key = list(points = FALSE, rectangles = TRUE, space = "right"),
panel = panel.superpose,
panel.groups = function(x, y, ..., group.number) {
panel.bwplot(x + (group.number-1.5)/3, y, ...)
})
這工作得很好,但我想箱圖是水平的,所以我改變了第一線,保持一切等於:
bwplot(class~hwy, data = mpg, groups = year, ...
但圖出來像這。我試圖玩弄代碼而沒有成功。我有兩個問題:首先,我怎麼能夠或者可以讓這些箱子互相疊加?第二,也是更普遍的是,我怎樣才能將彩色面板設置爲灰度,所以情節出現灰色或黑白兩色?
謝謝,'y +(group.numbers-1.5)/ 3)'技巧是一個漂亮! –