hafen / trelliscopejs

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

added scale_*_date/time to possible scale types #43

Closed schloerke closed 7 years ago

schloerke commented 7 years ago

Fixes issue #42 when dates are used on an axis

library(tidyverse)
#> Loading tidyverse: ggplot2
#> Loading tidyverse: tibble
#> Loading tidyverse: tidyr
#> Loading tidyverse: readr
#> Loading tidyverse: purrr
#> Loading tidyverse: dplyr
#> Conflicts with tidy packages ----------------------------------------------
#> filter(): dplyr, stats
#> lag():    dplyr, stats
library(trelliscopejs)
p <- economics_long[-(1:100), ] %>% ggplot(aes(date, value)) + geom_line()
p + facet_trelliscope(~variable, scales = "same", nrow = 2, ncol = 3, self_contained = TRUE)
#> using data from the first layer

p + facet_trelliscope(~variable, scales = "sliced", nrow = 2, ncol = 3, self_contained = TRUE)
#> using data from the first layer

p + facet_trelliscope(~variable, scales = "free", nrow = 2, ncol = 3, self_contained = TRUE)
#> using data from the first layer

hafen commented 7 years ago

Thanks @schloerke! Looks like I have some dplyr 0.7.0 stuff to fix too.

hafen commented 7 years ago

@schloerke, unrelated to dates, but related to axis scales, should an example like this work:

qplot(class, cty, data = mpg, geom = c("boxplot", "jitter")) +
    facet_trelliscope(~ class, ncol = 7, height = 800, width = 200,
      state = list(sort = list(sort_spec("cty_mean"))), path = "_test",
      scales = c("free", "same"))

With this, I would expect the y axis limits to be the same, correct?

screen shot 2017-06-16 at 4 19 11 pm
schloerke commented 7 years ago

Correct! Because of how dates work, I might have to set the range value manually.

I'll look later tonight On Fri, Jun 16, 2017 at 7:20 PM hafen notifications@github.com wrote:

@schloerke https://github.com/schloerke, unrelated to dates, but related to axis scales, should an example like this work:

qplot(class, cty, data = mpg, geom = c("boxplot", "jitter")) + facet_trelliscope(~ class, ncol = 7, height = 800, width = 200, state = list(sort = list(sort_spec("cty_mean"))), path = "_test", scales = c("free", "same"))

With this, I would expect the y axis limits to be the same, correct?

[image: screen shot 2017-06-16 at 4 19 11 pm] https://user-images.githubusercontent.com/1275592/27247662-a2790648-52af-11e7-96fc-3542fd4c695f.png

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/hafen/trelliscopejs/pull/43#issuecomment-309160492, or mute the thread https://github.com/notifications/unsubscribe-auth/AAFsL3UvPy86tiy8a75axzKVKvkE0O81ks5sEw24gaJpZM4N88fQ .

hafen commented 7 years ago

Cool thanks! I merged and did some stuff to make it work with dplyr 0.7 (really strange unnest() behavior).