robjhyndman / fpp2-package

All data sets required for the examples and exercises in the book "Forecasting: principles and practice" (2nd ed, 2018) by Rob J Hyndman and George Athanasopoulos <http://OTexts.org/fpp2/>. All packages required to run the examples are also loaded.
http://pkg.robjhyndman.com/fpp2-package/
105 stars 50 forks source link

adding arrows to gglagplot #7

Closed hope-data-science closed 4 years ago

hope-data-science commented 4 years ago

Gglagplot is a good displayment for lag plots, however, I could hardly find the direction of change. Therefore, I suggest adding an arrow to show the direction of change.

robjhyndman commented 4 years ago

@mitchelloharawild Maybe we could add time-direction arrows to gg_lagplot() in feasts?

mitchelloharawild commented 4 years ago

Do you mean like so?

library(feasts)
#> Loading required package: fabletools
library(tsibble)
library(dplyr)
tsibbledata::aus_retail %>%
  filter(
    State == "Victoria",
    Industry == "Cafes, restaurants and catering services"
  ) %>%
  gg_lag(Turnover, arrow = grid::arrow(length = grid::unit(2, "mm")))

Created on 2019-10-17 by the reprex package (v0.2.1)

robjhyndman commented 4 years ago

Yes. What do you think of adding arrow=TRUE as an argument in gg_lag?

mitchelloharawild commented 4 years ago

I think arrow should continue to be passed to geom_line() so that the angle and size of the arrow head can be specified. We can explain in the docs how arrows can be added, or we can also provide some other argument to create default arrows, such as direction or directional.

Although I presume there is a reason for why ggplot2 doesn't provide a convenient basic arrow when arrow=TRUE, so maybe there is an argument against having the direction shortcut.

hope-data-science commented 4 years ago

Excellent! Another thing might be that, how could we explain the direction properly in practice. When I know the track is continious I think an arrow might help, but what informative knowledge might it provide? Any ideas?

mitchelloharawild commented 4 years ago

As a lag plot shows the series values on the x axis with lagged values on the y axis, the arrows in the plot above indicate an upward trend. If the arrows were pointing in the other direction, the data contains a negative trend.

hope-data-science commented 4 years ago

A direction might also tell us when the series is coming near to the isoline, don't know if I'm right on this.