Skip to content

Instantly share code, notes, and snippets.

@yutannihilation
Last active May 31, 2017 13:31
Show Gist options
  • Save yutannihilation/67dcf87ad89ccc31b7a95e5cc61ba584 to your computer and use it in GitHub Desktop.
Save yutannihilation/67dcf87ad89ccc31b7a95e5cc61ba584 to your computer and use it in GitHub Desktop.
library(dplyr, warn.conflicts = FALSE)
library(ggplot2)

day <- lubridate::as_datetime(Sys.Date())
d <- tibble::tibble(
  x = day + lubridate::minutes(0:147 * 30),
  y = 0,
  day = lubridate::day(x)
)

ggplot(d) +
  geom_line(aes(x, y)) +
  facet_grid(day ~ ., scale = "free_x")

I wanted to draw something like:

l <- purrr::map(
  split(d, d$day),
  ~ ggplot(.) +
    geom_line(aes(x, y)) +
    facet_grid(day ~ ., scale = "free_x")
)
purrr::invoke(gridExtra::grid.arrange, l, ncol = 1)

@yutannihilation
Copy link
Author

ggplot(d) +
  geom_line(aes(x, y)) +
  facet_wrap(~ day, scale = "free_x", ncol = 1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment