2
# $Id: xw17.py 9904 2009-05-05 01:09:51Z airwin $
3
# Copyright 2002 Gary Bishop
4
# Copyright 2004 Alan W. Irwin
5
# This file is part of PLplot.
7
# PLplot is free software; you can redistribute it and/or modify
8
# it under the terms of the GNU Library General Public License as published by
9
# the Free Software Foundation; version 2 of the License.
11
# PLplot is distributed in the hope that it will be useful,
12
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
# GNU Library General Public License for more details.
16
# You should have received a copy of the GNU Library General Public License
17
# along with the file PLplot; if not, write to the Free Software
18
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20
# Plots a simple stripchart with four pens.
22
# Append to effective python path so that can find plplot modules.
23
from plplot_python_start import *
26
from plplot_py_demos import *
28
# Parse and process command line arguments
29
plparseopts(sys.argv, PL_PARSE_FULL)
34
from time import sleep
39
# If db is used the plot is much more smooth. However, because of the
40
# async X behaviour, one does not have a real-time scripcharter.
45
# User sets up plot completely except for window and data
46
# Eventually settings in place when strip chart is created will be
47
# remembered so that multiple strip charts can be used simultaneously.
50
# Specify some reasonable defaults for ymin and ymax
51
# The plot will grow automatically if needed (but not shrink)
56
# Specify initial tmin and tmax -- this determines length of window.
57
# Also specify maximum jump in t
58
# This can accomodate adaptive timesteps
62
tjump = 0.3 # percentage of plot to jump
64
# Axes options same as plbox.
65
# Only automatic tick generation and label placement allowed
66
# Eventually I ll make this fancier
70
styline = [2, 3, 4, 5]
71
colline = [2, 3, 4, 5]
73
legline = ["sum", "sin", "sin*noi", "sin+noi"]
76
ylab = 0.25 # legend position
78
autoy = 1 # autoscale y
79
acc = 1 # don t scrip, accumulate
84
# Register our error variables with PLplot
85
# From here on, we're handling all errors here
87
#plsError(&pl_errcode, errmsg)
89
id1 = plstripc("bcnst", "bcnstv",
90
tmin, tmax, tjump, ymin, ymax,
94
colline, styline, legline,
95
"t", "", "Strip chart demo")
97
# Let plplot handle errors from here on
101
autoy = 0 # autoscale y
104
# This is to represent a loop over time
105
# Let's try a random walk process
107
y1 = y2 = y3 = y4 = 0.0
110
for n in range(nsteps):
113
noise = plrandd() - 0.5
119
# There is no need for all pens to have the same number of
120
# points or beeing equally time spaced.
123
plstripa(id1, 0, t, y1)
125
plstripa(id1, 1, t, y2)
127
plstripa(id1, 2, t, y3)
129
plstripa(id1, 3, t, y4)
131
# Destroy strip chart and it's memory
135
# No defaults changed so nothing to restore