hafen / trelliscopejs

TrelliscopeJS R Package
https://hafen.github.io/trelliscopejs
Other
263 stars 37 forks source link

facet_trelliscope scales #26

Closed schloerke closed 7 years ago

schloerke commented 7 years ago

works with

library(ggplot2)

mpg2 <- mpg
mpg2$drv <- as.factor(mpg2$drv)
mpg2$cyl <- as.factor(mpg2$cyl)

for_types <- function(p, formu = ~ drv) {
  for (type in c("free", "same", "sliced")) {
    q <- p +
      labs(title = type) +
      facet_trelliscope(formu, ncol = 3, nrow = 1, scales = type)
    print(q)
  }
}

for_types(qplot(displ, hwy, data = mpg2))

for_types(qplot(displ, hwy, data = mpg2) + facet_wrap(~ fl))

for_types(qplot(cyl, hwy, data = mpg2, geom = "violin") + coord_flip())

# fails for auto-cog computation, but would theoretically work for the faceting.
for_types(qplot(displ, hwy, data = mpg2), ~ hwy > 20)