| Locate Previous | Contents |
We have already seen that in Rain it is easy to display time series data. Personally I prefer to be in charge of the axes, so we will use the 'xyplot' option for the chart. Then we have the option that the x-values corresponding to the tick-marks can be converted into dates.
day1
prod1
l½time
tday+7×0,¼¯1+l÷7
chSet 'style' 'boxed,xyplot'
chSet 'xstyle' 'date'
chPlot time[t],[1.5]demand[t;prod]
psView PGchClose
This can easily be expanded into a program dts day prod which allows all possible time series for the different days and the different products to be produced:
dts prod_day;day;prod;ts;d;p;w
prod dayprod_day
© produce a time series for the different days
© of the week and for the different products
tstime,demand ª w½time
chSet'style' 'boxed,xyplot'
d'Sunday' 'Monday' 'Tuesday' 'Wednesday' 'Thursday' 'Friday' 'Saturday' '
p'Sliced Bread' 'Unsliced Bread' 'Organic Bread'
chSet'head' 'Time Series for',(p[prod]),' on Day',d[day]
chSet'xstyle' 'date'
chPlot ts[day+7×0,¼¯1+w÷7;1,1+prod]
To see the result, simply type psView PGchClose from the session manager. (We have omitted the command deliberately.)
Alternatively, if you want to view all three of the different products for a given day, then it is sensible to provide a key:
allprod day;prod;ts;d;p;w
© produce time series for the different products
tstime,demand ª w½time
chSet'style' 'boxed,xyplot'
d'Sunday' 'Monday' 'Tuesday' 'Wednesday' 'Thursday' 'Friday' 'Saturday' '
p'Sliced Bread' 'Unsliced Bread' 'Organic Bread'
chSet'head' 'Time Series for all products on ',d[day]
chSet'xstyle' 'date'
chSet'key' 'Sliced,Unsliced,Organic'
chPlot ts[day+7×0,¼¯1+w÷7;]
psView PGchClose
allprod 3
If you want to see all possible 21 combinations of products and days, then the program MbyN comes in handy it divides the plotting region into M×N regions (specified by the left argument) and executes each line of the character matrix right argument:
3 7 MbyN (21 4½'dts '),21 1½¼3 7
This works by using the command chNew as explained in the next section.