This question seems difficult to understand, but to illustrate, I bring a figure as an example:
I am trying to replicate this graph. So far I've done the graphics separately, but I don't know how I can put them together as in the example.
Any help?
time <- seq(from = 0,
            to = 10,
            by = 0.5)
line_1 <- c(0, 0, 0, 66, 173, 426, 1440, 800, 1200, 400, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
line_2 <- c(0, 0, 0, 0, 0, 0, 0, 0, 1000, 25000, 5000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0)
df <- data.frame(time, line_1, line_2)
library(ggpubr)
#the plot
ggplot(data = df, aes(x = time)) +
  geom_line(aes(y = line_2), color = "red",
            position = position_nudge(x = 0.5, y = 1000)) +
  geom_line(aes(y = line_1),color = "blue") +
  geom_rect(aes(xmin = 1, xmax = 5, ymin = 0, ymax = 1500), color = "black", alpha = 0) +
  theme_pubr( base_size = 8,
              border = TRUE)
#The plot with a zoom
ggplot(data = df, aes(x = time, y = line_1)) +
  geom_line(color = "blue") +
  xlim (1, 5) +
  ylim (0, 1500) +
  theme_pubr( base_size = 8,
              border = TRUE)




