TimeSeriesAnalysis
TimeSeriesPlot
display time series data
Calling Sequence
Parameters
Description
Specifying Colors
The split Option
Examples
Compatibility
TimeSeriesPlot(ts1)
TimeSeriesPlot(ts1, ts2, [ts3, opt1, opt2], ts4, opt3, opt4)
ts1, ts2, ts3, ts4
-
TimeSeries objects
opt1, opt2, opt3, opt4
plot options of the form optionname = value; options not inside lists such as opt3 and opt4 can also have the form split = value (see below)
The TimeSeriesPlot command is used for visualizing time series data. It can show multiple data sets of different time series with one invocation, possibly with different plot options for different time series. Moreover, the data sets can be shown in a single plot or they can be split into multiple plots.
The first calling sequence above creates a plot with all data sets from a single time series in it, and default plot options.
The second calling sequence shows an example of how you can plot multiple time series. You do this by submitting a sequence consisting of time series and/or lists, in arbitrary order. If lists are included, then the first element of each such list should be a time series, and all other elements should be plot options: these plot options apply only to the time series in the list. In addition, more plot options can be given after all time series; these options apply to all time series. For example, to change the size of a plot, you can use the size option; the default used for time series plots is size=0.75,0.35. If an option is given both outside of lists and in a list with a time series, then for that time series the option specified in the list takes precedence.
If you want all curves in the resulting plot to be the same color, you can use the color option as specified on the help page for plot options. Similarly, if you want all curves of a time series to be the same color, you can put that time series in a list and add the color option to that list.
You can also specify different colors as a list:
If you specify colors as a list for a color option occurring outside a list, the colors are applied to all data sets of all time series. In this case, the number of colors specified must be at least the number of data sets occurring in all time series given.
Alternatively, if you specify colors as a list for a color option included in a list with a time series, then the colors are applied to the data sets of this time series only. In this case, the number of colors specified must be at least the number of data sets occurring in the time series to which the option applies.
The TimeSeriesPlot command also supports using a range of colors for either all data sets in one time series, or all data sets processed by the command. This is done with the option color = C1 .. C2, where C1 and C2 are specifications of colors such that color = C1 and color = C2 are valid color options. Such an option can be applied to the whole command, or to an individual time series. This feature uses the ColorTools[Gradient] command.
The split option can be used to split the display of data sets into several plots, displayed as an array plot. There are several ways this can be specified:
split = separate
This option makes a separate plot in the plot array for each data set.
split = pertimeseries
This option makes a separate plot for each time series, containing all data sets from that time series.
split = together
This option makes a single plot containing all data sets from all time series.
split = automatic
This option behaves like split = together, except for time series resulting from the TimeSeriesAnalysis[Decomposition] command. Such time series are separated out from the rest and all their data sets get a separate plot.
split = [spec1, spec2, ...]
Using a list for the value of the split option, you can fully customize how the data sets are distributed over plots. Each item in the list is a specification for a single plot in the array plot that is generated. You can use several types of items in these lists:
The first possibility is a list [ts, is1, is2, ...] where the first element is one of the time series you have specified, and the subsequent elements are either positive integers or strings. These elements select data sets from the time series: a positive integer is1 selects the data set in the is1th column of ts; a string is2 selects the data set with header is2. The result is to select all of the data sets given by these integers and/or strings.
The second possibility is a time series ts. This selects all data sets from this time series; it is equivalent to the list [ts, 1, 2, ..., k], where k is the number of data sets in ts.
The final possibility is a set {e1, e2, ...}, where each of element is either a list or a time series as explained in the previous two bullet points; this represents all of the data sets selected by each of e1, e2, and so on.
An example would be TimeSeriesPlot(ts1, ts2, ts3, split = [ts1, [ts2, 2, 3], {[ts2, 1], ts3}]), where ts2 is a time series with at least three data sets. This would split the data sets into three plots: one for all data sets in ts1, one for the second and third data set in ts2, and one for the first data set in ts2 and all data sets in ts3.
with⁡TimeSeriesAnalysis:
A basic example.
ts1≔TimeSeries⁡0.29,0.66,1.22,0.69,0.18,0.31,1.94,0.11,1.72,frequency=monthly,header=A,enddate=2013-08
ts1≔Time seriesA9 rows of data:2012-12-01 - 2013-08-01
TimeSeriesPlot⁡ts1
Using plot options.
TimeSeriesPlot⁡ts1,color=red,thickness=3
Because there is only one time series, in this case it would be the same to specify these plot options in a list together with the time series.
We add two more time series with several data sets.
ts2≔TimeSeries⁡5.89,7.38,6.45,6.05,5.61,6.44,5.79,4.84,4.08,3.90,3.75,3.67,5.10,4.36,3.42,3.15,3.72,3.01,2.33,2.35,1.45,0.92,0.54,1.24,1.39,1.20,0.12,1.47,0.36,1.84,1.30,4.94,0.77,0.55,0.25,0.03,0.31,0.90,1.85,0.66,2.83,0.38,3.66,6.85,0.80,0.89,0.45,0.91,1.71,1.81,frequency=weekly,headers=B,C,enddate=2013-07-24
ts2≔Time seriesB, C25 rows of data:2013-02-06 - 2013-07-24
ts3≔TimeSeries⁡102.,137.,113.,115.,146.,110.,116.,106.,107.,108.,115.,125.,143.,124.,111.,107.,124.,130.,101.,106.,104.,139.,140.,165.,142.,114.,101.,197.,113.,127.,128.,125.,122.,115.,113.,107.,110.,106.,99.2,93.2,86.7,95.6,90.2,85.0,78.9,75.7,70.2,66.2,79.5,74.6,76.2,73.2,69.5,67.1,68.0,86.3,81.3,75.0,76.5,86.0,3.15,2.44,6.64,10.7,12.8,11.6,10.9,9.66,13.8,14.1,13.2,14.2,13.2,13.7,13.5,12.7,11.4,11.8,10.6,11.9,10.7,9.69,9.36,8.95,10.6,9.77,9.45,8.26,9.25,8.57,frequency=weekly,headers=D,E,F,enddate=2013-08-10
ts3≔Time seriesD, E, F30 rows of data:2013-01-19 - 2013-08-10
By default, these time series will all be shown in a single plot.
TimeSeriesPlot⁡ts1,ts2,ts3
Because the quantities differ by orders of magnitude, this is not particularly useful. It is better to split the data sets into two plots. All data sets in time series ts1 and ts2, and data set F from time series ts3, have smaller values, whereas data sets D and E from time series ts3 have larger values.
TimeSeriesPlot⁡ts1,ts2,ts3,split=ts1,ts2,ts3,F,ts3,D,E
We can make it clearer which data set comes from which time series by specifying colors. We specify the colors for ts2 and ts3 explicitly for the given time series by including it in the list, and specify that all other time series (in this case ts1) are colored red by including a color option outside these lists.
For the split option, this time we use numbers to specify the data sets in ts3, to the same effect as using strings before.
TimeSeriesPlot⁡ts1,ts2,color=LightGreen,LightBlue,ts3,color=Purple..Brown,color=red,split=ts1,ts2,ts3,3,ts3,1,2
Alternatively, we can specify all of the colors for all of the data sets in a single list.
TimeSeriesPlot⁡ts1,ts2,color=Red,Green,Blue
We can split these three data sets into three plots, or group them per time series.
TimeSeriesPlot⁡ts1,ts2,split=separate
TimeSeriesPlot⁡ts1,ts2,split=pertimeseries
If a forecast and several confidence intervals are submitted, and the split option is not used (or equivalently, you use split = automatic), they are generally displayed in a single plot. An example follows.
ts3e≔ts3..,E
ts3e≔Time seriesE30 rows of data:2013-01-19 - 2013-08-10
model≔ExponentialSmoothingModel⁡ts3e
model≔< an ETS(A,N,N) model >
cis≔Forecast⁡model,ts3e,4,output=confidenceintervals⁡80,95
cis≔Time seriesE (forecast - 2 percentile), ..., E (forecast - 98 percentile)4 rows of data:2013-08-16 - 2013-09-06
TimeSeriesPlot⁡ts3e,cis..,3,cis..,1,2,4,5,color=blue..green,color=red
A decomposition, however, is shown in separate plots by default.
dc≔Decomposition⁡model,ts3e
dc≔Time seriesE (residuals), E (level)30 rows of data:2013-01-19 - 2013-08-10
TimeSeriesPlot⁡dc
To show the curves together, use split = together.
TimeSeriesPlot⁡dc,split=together
If we plot all these items together, the decomposition will be split out, but the other elements will be shown together.
TimeSeriesPlot⁡dc,ts3e,cis..,3,cis..,1,2,4,5,color=blue..green,color=red
The TimeSeriesAnalysis[TimeSeriesPlot] command was introduced in Maple 18.
For more information on Maple 18 changes, see Updates in Maple 18.
See Also
TimeSeriesAnalysis[SeasonalSubseriesPlot]
Download Help Document