如何更改格子图中的填充颜色?

how to change the fill color in a lattice plot?

考虑这个例子

library(tibble)
library(lubridate)
library(lattice)
library(latticeExtra)

df <- tibble(time = c(ymd('2019-01-01'),
                ymd('2019-01-02'),
                ymd('2019-01-03'),
                ymd('2019-01-01'),
                ymd('2019-01-02'),
                ymd('2019-01-03')),
       variable = c('a','a','a','b','b','b'),
       value = c(1,2,3,0,0,2))

# A tibble: 6 x 3
  time       variable value
  <date>     <chr>    <dbl>
1 2019-01-01 a            1
2 2019-01-02 a            2
3 2019-01-03 a            3
4 2019-01-01 b            0
5 2019-01-02 b            0
6 2019-01-03 b            2

我正在尝试重现 ggplot

中的堆积面积图
  df %>% ggplot(aes(x = time, y = value, fill = variable)) +
  geom_area()

我已经差不多了,但是下面的例子着色不对

  df  %>%  group_by(time) %>% 
  mutate(value = ifelse(variable == 'a', sum(value), value)) %>% 
  ungroup() %>% 
  xyplot(value~time, data = ., group=variable,
     panel=function(x,y,...){
     panel.xyarea(x,y,...)
     panel.xyplot(x,y,...)},
     col=c("red","blue"),
     alpha=c(0.8,0.4)) 

有什么想法吗?谢谢!

这是一种解决方案,使用 simpleTheme:

df  %>%  group_by(time) %>% 
     mutate(value = ifelse(variable == 'a', sum(value), value)) %>% 
     ungroup() %>% 
     xyplot(value~time, data = ., group=variable,
            panel=function(x,y,...){
                panel.xyarea(x,y,...)
                panel.xyplot(x,y,...)}, par.settings=simpleTheme(col=c("red", "blue")))

希望这就是您要找的。