Consider this simple example
library(lubridate)
library(lattice)
library(latticeExtra)
library(tibble)
library(dplyr)
mydf <- tibble(time = c(ymd('2019-01-01'),
ymd('2019-01-02'),
ymd('2019-01-03'),
ymd('2019-01-04'),
ymd('2019-01-05')),
var1 = c(2,2,2,2,1),
var2 = c(2,1,1,4,5),
var3 = c(200, 200, 400, 500, 230))
Now this works
p1 <- mydf %>%
barchart(var1 + var2 ~ time,
data = .,
stack = TRUE,
horiz = FALSE,
par.settings = simpleTheme(col = c('red', 'blue'),
fill = c('red', 'blue'),
alpha = c(0.2)),
auto.key = TRUE)
and this works as well
p2 <- mydf %>%
xyplot(var3 ~ time, data = ., type = 'l')
However, combining them with latticeExtra::doubleYscale()
does not work. The line is invisible (see below)
latticeExtra::doubleYScale(p1, p2, use.style = FALSE)
Strangely enough, the dual y scale is there, but the line is missing. Any ideas?
Thanks!!