A seasonal plot is similar to a time plot except that the data are plotted against the individual “seasons” in which the data were observed. An example is given in Figure 2.4 showing the antidiabetic drug sales.
%>% a10 gg_season(Cost, labels = "both") + labs(y = "$ (millions)", title = "Seasonal plot: Antidiabetic drug sales")
These are exactly the same data as were shown earlier, but now the data from each season are overlapped. A seasonal plot allows the underlying seasonal pattern to be seen more clearly, and is especially useful in identifying years in which the pattern changes.
In this case, it is clear that there is a large jump in sales in January each year. Actually, these are probably sales in late December as customers stockpile before the end of the calendar year, but the sales are not registered with the government until a week or two later. The graph also shows that there was an unusually small number of sales in March 2008 (most other years show an increase between February and March). The small number of sales in June 2008 is probably due to incomplete counting of sales at the time the data were collected.
Where the data has more than one seasonal pattern, the
period argument can be used to select which seasonal plot is required. The
vic_elec data contains half-hourly electricity demand for the state of Victoria, Australia. We can plot the daily pattern, weekly pattern or yearly pattern by specifying the
period argument as shown in Figures 2.5–2.7.
In the first plot, the three days with 25 hours are when daylight saving ended in each year and so these days contained an extra hour. There were also three days with only 23 hours each (when daylight saving started) but these are hidden beneath all the other lines on the plot.
%>% gg_season(Demand, period = "day") + vic_elec theme(legend.position = "none") + labs(y="MWh", title="Electricity demand: Victoria")
%>% gg_season(Demand, period = "week") + vic_elec theme(legend.position = "none") + labs(y="MWh", title="Electricity demand: Victoria")
%>% gg_season(Demand, period = "year") + vic_elec labs(y="MWh", title="Electricity demand: Victoria")