tidyverts / feasts

Feature Extraction And Statistics for Time Series
https://feasts.tidyverts.org/
291 stars 23 forks source link

Duplicate x label in gg_season() #116

Closed robjhyndman closed 3 years ago

robjhyndman commented 4 years ago

See December in the following.

library(feasts)
#> Loading required package: fabletools
USAccDeaths %>% as_tsibble() %>% gg_season(value)

Created on 2020-08-24 by the reprex package (v0.3.0)

mitchelloharawild commented 4 years ago

Thanks. This is due to a leap year in the data, causing an off-by-one when the dates are aligned to a fixed origin. I've made a smarter fix for the scale_x_year* tsibble classes now which retains the tsibble class in the plot.

This should be easier/better with origin agnostic/optional time classes in a future package.

robjhyndman commented 4 years ago

Now it gives a quarterly time axis for monthly data.

library(tsibble)
library(feasts)
#> Loading required package: fabletools

USAccDeaths %>% as_tsibble() %>% gg_season(value)

Created on 2020-08-25 by the reprex package (v0.3.0)

It also requires library(tsibble) or it fails to find scale_x_yearmonth.

mitchelloharawild commented 4 years ago

The breaks (Q1-Q4) should be improved in tsibble's scale_x_yearmonth() defaults, and there isn't a nice way to fix this in feasts (as the tsibble scale functions don't pass ... through to pretty(), https://github.com/tidyverts/tsibble/issues/216) I'll fix the scoping issue.

mitchelloharawild commented 4 years ago

I've added a fallback to date for the breaks for now, which gives the desired result:

library(feasts)
#> Loading required package: fabletools
USAccDeaths %>% as_tsibble() %>% gg_season(value)

Created on 2020-08-25 by the reprex package (v0.3.0)