| 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
ch.Set 'style' 'boxed,xyplot'
ch.Set 'xstyle' 'date'
ch.Plot time[t],[1.5]demand[t;prod]
View PGch.Close
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
ch.Set'style' 'boxed,xyplot'
d'Sunday' 'Monday' 'Tuesday' 'Wednesday' 'Thursday' 'Friday' 'Saturday' '
p'Sliced Bread' 'Unsliced Bread' 'Organic Bread'
ch.Set'head' 'Time Series for',(p[prod]),' on Day',d[day]
ch.Set'xstyle' 'date'
ch.Plot ts[day+7×0,¼¯1+w÷7;1,1+prod]
To see the result, simply type View PGch.Close 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
ch.Set'style' 'boxed,xyplot'
d'Sunday' 'Monday' 'Tuesday' 'Wednesday' 'Thursday' 'Friday' 'Saturday' '
p'Sliced Bread' 'Unsliced Bread' 'Organic Bread'
ch.Set'head' 'Time Series for all products on ',d[day]
ch.Set'xstyle' 'date'
ch.Set'key' 'Sliced,Unsliced,Organic'
ch.Plot ts[day+7×0,¼¯1+w÷7;]
View PGch.Close
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 ch.New as explained in the next section.