是否有一种方法可以合并不同的lattice
barchart
图来获得堆叠的barchart
? (我可以使用as.layer
,但是这两个图是彼此相对而不是堆叠的。例如:
library(lattice); library(dplyr); library(latticeExtra)
# sample data
barley %>% filter(variety %in% c("Trebi","Velvet","Peatland"))
b1 <- barley %>% filter(site == "Morris")
b2 <- barley %>% filter(site == "Duluth")
b1a2 <- barley %>% filter(site %in% c("Morris","Duluth"))
# stacked plot
plotorg <- barchart(yield ~ variety | year, data = b1a2,
groups = site, stack = TRUE)
# two barcharts that I want stack together
plot1 <- barchart(yield ~ variety | year, data = b1,
groups = site, stack = TRUE)
plot2 <- barchart(yield ~ variety | year, data = b2,
groups = site, stack = TRUE)
plot1 + plot2 # bars are behind each other and not stacked