Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plot labels for incomplete time series #4

Closed
camroach87 opened this issue Dec 1, 2017 · 2 comments
Closed

Plot labels for incomplete time series #4

camroach87 opened this issue Dec 1, 2017 · 2 comments

Comments

@camroach87
Copy link

Hi Earo, great work with sugrrants - been using it lots. As discussed noticed some odd behaviour when using facet_wrap with an incomplete time series. Reproducible example to play around with below.

rm(list=ls())

require(sugrrants)
require(lubridate)
require(dplyr)
require(tidyr)

n_days <- 365
n_groups <- 4
start_date <- dmy("1/1/2010")
bla <- data.frame(Group = rep(LETTERS[1:n_groups], each = 24*n_days),
                  Date = rep(start_date + days(0:(n_days-1)), each = 24),
                  Time = rep(1:24, n_groups*n_days),
                  Value = rnorm(24*n_days*n_groups)) %>% 
  filter(!(Group == "B" & month(Date) %in% 5:12))

p <- bla %>% 
  group_by(Group) %>% 
  frame_calendar(x = Time, y = Value, date = Date,
                 calendar = "monthly", ncol = 2) %>% 
  ggplot(aes(x = .Time, y = .Value, group = Date)) +
  geom_line() +
  facet_wrap(~Group)
prettify(p)

You'll see the plot for Group B has it's time-series stretched to fill all the space, but the plot labels are the same as for all the other groups.

@camroach87
Copy link
Author

I think rather than changing the position of plot labels for one plot it would probably be most useful if the incomplete time series was padded with NAs so that it was on the same scale as other time-series.

@camroach87
Copy link
Author

Closing as duplicates #3

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

No branches or pull requests

2 participants