Consider this simple example
library(tidyverse)
library(lubridate)
library(patchwork)
df1 <- tibble(time = c(ymd_hms('2019-10-01 10:00:00.123'),
ymd_hms('2019-10-01 10:01:00.123'),
ymd_hms('2019-10-01 10:02:00.123'),
ymd_hms('2019-10-01 10:03:00.123')),
value = c(1,2,3,4))
df2 <- tibble(time = c(ymd_hms('2019-10-01 10:02:00.123'),
ymd_hms('2019-10-01 10:03:00.123'),
ymd_hms('2019-10-01 10:04:00.123')),
value = c(20, 30, 40))
p1 <- df1 %>% ggplot(aes(x = time, y = value)) + geom_line()
p2 <- df2 %>% ggplot(aes(x = time, y = value)) + geom_line()
p1/p2
this gives
However, I would like the plots to be aligned on the x
axis. Is that possible?
Thanks!