1## Copyright (C) 1998, 1999, 2000  Joao Cardoso
2## Copyright (C) 2004  Rafael Laboissiere
3##
4## This program is free software; you can redistribute it and/or modify it
5## under the terms of the GNU General Public License as published by the
6## Free Software Foundation; either version 2 of the License, or (at your
7## option) any later version.
8##
9## This program is distributed in the hope that it will be useful, but
10## WITHOUT ANY WARRANTY; without even the implied warranty of
11## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12## General Public License for more details.
13##
14## This file is part of plplot_octave.
15## It is based on the corresponding demo function of PLplot.
16
17function x17c
18
19  nsteps = 1000;
20
21  ## If db is used the plot is much more smooth. However, because of the
22  ## async X behaviour, one does not have a real-time scripcharter.
23  ##    plSetOpt("db", "");
24
25  ## plSetOpt("np", "");
26
27  ## Specify some reasonable defaults for ymin and ymax */
28  ## The plot will grow automatically if needed (but not shrink) */
29
30  ymin = -0.1;
31  ymax =  0.1;
32
33  ## Specify initial tmin and tmax -- this determines length of window. */
34  ## Also specify maximum jump in t */
35  ## This can accomodate adaptive timesteps */
36
37  tmin = 0.;
38  tmax = 10.;
39  tjump = 0.3;	## percentage of plot to jump
40
41  ## Axes options same as plbox. */
42  ## Only automatic tick generation and label placement allowed */
43  ## Eventually I'll make this fancier */
44
45  colbox = 1;
46  collab = 3;
47  styline(1) = colline(1) = 2;	## pens color and line style
48  styline(2) = colline(2) = 3;
49  styline(3) = colline(3) = 4;
50  styline(4) = colline(4) = 5;
51
52  ##    legline = ["sum"; "sin"; "sin*noi"; "sin+noi";];
53
54
55  xlab = 0.; ylab = 0.25;	## legend position
56
57  autoy = 1;	## autoscale y
58  acc = 1;	## dont strip, accumulate
59
60  ## Initialize plplot */
61  plinit();
62  pladv(0);
63  plvsta();
64  id1= plstripc("bcnst", "bcnstv",
65		tmin, tmax, tjump, ymin, ymax,
66		xlab, ylab,
67		autoy, acc,
68		colbox, collab,
69		colline', styline', "sum", "sin", "sin*noi", "sin+noi",
70		"t", "", "Strip chart demo");
71
72  autoy = 0;
73  acc = 1;
74
75  ## This is to represent a loop over time */
76  ## Let's try a random walk process */
77
78  y1 = y2 = y3 = y4 = 0.0;
79  dt = 0.1;
80
81  for n = 0:nsteps-1
82    t = n * dt;
83    noise = plrandd()-0.5;
84    y1 = y1 + noise;
85    y2 = sin(t*pi/18.);
86    y3 = y2 * noise;
87    y4 = y2 + noise/3.;
88
89    ## there is no need for all pens to have the same number of points
90    ## or beeing equally time spaced.
91
92    if (rem(n,2))
93      plstripa(id1, 0, t, y1);
94    endif
95    if rem(n,3)
96      plstripa(id1, 1, t, y2);
97    endif
98    if rem(n,4)
99      plstripa(id1, 2, t, y3);
100    endif
101    if rem(n,5)
102      plstripa(id1, 3, t, y4);
103    endif
104  endfor
105
106  ## Destroy strip chart and it's memory */
107
108  plstripd(id1);
109  plend1();
110
111endfunction
112