seq_x_tb <- seq(from = -0.5,
to = 2.5 * pi,
by = pi / 100)
n_lines <- 11
data_top_and_bottom <- tibble(x = rep(seq_x_tb, 9),
line = rep(seq(-1, 7), each = length(seq_x_tb))) %>%
mutate(y = line + sin(x))
data_arrows_bottom_and_top <- data_top_and_bottom %>%
filter(x %in% c(seq_x_tb[c(length(seq_x_tb) / 2 -1 , length(seq_x_tb) / 2 + 1)]),
between(line, 1, 6)) %>%
group_by(line) %>%
summarise(xmin = min(x),
xmax = max(x),
ymax = max(y),
ymin = min(y))
gg_top_to_bottom <- data_top_and_bottom %>%
ggplot(aes(y = x, x = y, group = line)) +
geom_segment(data = data_arrows_bottom_and_top,
aes(y = xmin, x = ymax, yend = xmax, xend = ymin, group = line),
arrow = arrow(type="closed", ends = "first"), linewidth = 5, show.legend = FALSE) +
geom_path(linewidth = 5,
show.legend = FALSE,
aes(colour = ifelse(between(line, 1, 6), "main", "background"))) +
scale_x_continuous(expand = expansion(0, -0.1)) +
scale_y_continuous(expand = expansion(0, 0)) +
scale_colour_manual(values = c("main" = "black",
"background" = "grey80")) +
coord_fixed(ratio = 1 / 2, ylim = c(0, 7), xlim = c(0, 2 * pi)) +
theme_void() +
theme(
panel.background = element_rect(fill = "#9A7D66", colour = "transparent"),
panel.border = element_blank()
)
gg_bottom_to_top <- data_top_and_bottom %>%
ggplot(aes(y = x, x = y, group = line)) +
geom_segment(data = data_arrows_bottom_and_top,
aes(y = xmin, x = ymax, yend = xmax, xend = ymin, group = line),
arrow = arrow(type="closed", ends = "last"), linewidth = 5, show.legend = FALSE) +
geom_path(linewidth = 5,
show.legend = FALSE,
aes(colour = ifelse(between(line, 1, 6), "main", "background"))) +
scale_x_continuous(expand = expansion(0, -0.1)) +
scale_y_continuous(expand = expansion(0, 0)) +
scale_colour_manual(values = c("main" = "black",
"background" = "grey80")) +
coord_fixed(ratio = 1 / 2, ylim = c(0, 7), xlim = c(0, 2 * pi)) +
theme_void() +
theme(
panel.background = element_rect(fill = "#9A7D66", colour = "transparent"),
panel.border = element_blank()
)
(gg_top_to_bottom + theme(plot.margin = margin(r = 20)) | gg_bottom_to_top)