Skip to content

Commit 9e0b922

Browse files
committed
demo.py: I wait=1 instead of sleep()
1 parent d01a4f0 commit 9e0b922

1 file changed

Lines changed: 42 additions & 50 deletions

File tree

demo.py

Lines changed: 42 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
y_3d = (np.cos(ph) * np.sin(th)) .ravel()
1818
z_3d = (np.sin(ph) * np.ones( th.shape )) .ravel()
1919

20-
sleep_interval = 1
2120

2221

2322

@@ -29,26 +28,20 @@
2928

3029
# first, some very basic stuff. Testing implicit domains, multiple curves in
3130
# arguments, packed broadcastable data, etc
32-
gp.plot(x**2)
33-
time.sleep(sleep_interval)
34-
gp.plot(-x, x**3)
35-
time.sleep(sleep_interval)
36-
gp.plot((x**2))
37-
time.sleep(sleep_interval)
38-
gp.plot((-x, x**3, {'with': 'lines'}), (x**2,))
39-
time.sleep(sleep_interval)
40-
gp.plot( x, np.vstack((x**3, x**2)) )
41-
time.sleep(sleep_interval)
42-
gp.plot( np.vstack((-x**3, x**2)), _with='lines' )
43-
time.sleep(sleep_interval)
44-
gp.plot( (np.vstack((x**3, -x**2)), {'with': 'points'} ))
45-
time.sleep(sleep_interval)
31+
gp.plot(x**2, wait=1)
32+
gp.plot(-x, x**3, wait=1)
33+
gp.plot((x**2), wait=1)
34+
gp.plot((-x, x**3, {'with': 'lines'}), (x**2,), wait=1)
35+
gp.plot( x, np.vstack((x**3, x**2)) , wait=1)
36+
gp.plot( np.vstack((-x**3, x**2)), _with='lines' , wait=1)
37+
gp.plot( (np.vstack((x**3, -x**2)), {'with': 'points'} ), wait=1)
4638

4739
#################################
4840
# some more varied plotting, using the object-oriented interface
4941
plot1 = gp.gnuplotlib(_with = 'linespoints',
5042
xmin = -10,
51-
title = 'Error bars and other things')
43+
title = 'Error bars and other things',
44+
wait = 1)
5245

5346
plot1.plot( ( np.vstack((x, x*2, x*3)), x**2 - 300,
5447
{'with': 'lines lw 4',
@@ -63,7 +56,6 @@
6356
{"with": 'lines',
6457
'legend': 'shifted cubics',
6558
'tuplesize': 2}))
66-
time.sleep(sleep_interval)
6759

6860
#################################
6961

@@ -75,14 +67,14 @@
7567
gp.plot( x**2, np.abs(x)/2, x*50,
7668
cbrange = '-600:600',
7769
_with = 'points pointtype 7 pointsize variable palette',
78-
tuplesize = 4 )
79-
time.sleep(sleep_interval)
70+
tuplesize = 4,
71+
wait = 1)
8072

8173
# labels
8274
gp.plot(np.arange(5),np.arange(5)+1,
8375
np.array( ['{} {}'.format(x,x+1) for x in range(5)], dtype=str),
84-
_with='labels', tuplesize=3, ascii=1)
85-
time.sleep(sleep_interval)
76+
_with='labels', tuplesize=3, ascii=1,
77+
wait = 1)
8678

8779
# Conchoids of de Sluze. Broadcasting example
8880
theta = np.linspace(0, 2*np.pi, 1000) # dim=( 1000,)
@@ -94,8 +86,8 @@
9486
set = 'polar',
9587
square = True,
9688
yrange = [-5,5],
97-
legend = a.ravel() )
98-
time.sleep(sleep_interval)
89+
legend = a.ravel(),
90+
wait = 1)
9991

10092

10193
################################
@@ -107,8 +99,8 @@
10799
_with = 'points',
108100
title = 'sphere',
109101
square = True,
110-
legend = 'sphere')
111-
time.sleep(sleep_interval)
102+
legend = 'sphere',
103+
wait = 1)
112104

113105
# sphere, ellipse together
114106
gp.plot3d( (x_3d * np.array([[1,2]]).T,
@@ -118,8 +110,8 @@
118110

119111
title = 'sphere, ellipse',
120112
square = True,
121-
_with = 'points')
122-
time.sleep(sleep_interval)
113+
_with = 'points',
114+
wait = 1)
123115

124116

125117
# similar, written to a png
@@ -131,8 +123,8 @@
131123
title = 'sphere, ellipse',
132124
square = True,
133125
_with = 'points',
134-
hardcopy = 'spheres.png')
135-
time.sleep(sleep_interval)
126+
hardcopy = 'spheres.png',
127+
wait = 1)
136128

137129

138130

@@ -144,8 +136,8 @@
144136
(-z, {'legend': 'zminus'}),
145137
(z*2, {'legend': 'zplus2'}),
146138

147-
_with = 'points', title = 'gridded paraboloids', ascii=True)
148-
time.sleep(sleep_interval)
139+
_with = 'points', title = 'gridded paraboloids', ascii=True,
140+
wait = 1)
149141

150142
# 3d, variable color, variable pointsize
151143
th = np.linspace(0, 6*np.pi, 200)
@@ -159,8 +151,8 @@
159151

160152
title = 'double helix',
161153
tuplesize = 5,
162-
_with = 'points pointsize variable pointtype 7 palette' )
163-
time.sleep(sleep_interval)
154+
_with = 'points pointsize variable pointtype 7 palette',
155+
wait = 1)
164156

165157

166158
# implicit domain heat map
@@ -169,8 +161,8 @@
169161
gp.plot3d(z,
170162
title = 'Paraboloid heat map',
171163
set = 'view map',
172-
_with = 'image')
173-
time.sleep(sleep_interval)
164+
_with = 'image',
165+
wait = 1)
174166

175167
# same, but as a 2d gp.plot, _with a curve drawn on top for good measure
176168
x,y = np.ogrid[-10:11, -10:11]
@@ -187,8 +179,8 @@
187179
xmin = 0,
188180
xmax = 20,
189181
ymin = 0,
190-
ymax = 20 )
191-
time.sleep(sleep_interval)
182+
ymax = 20,
183+
wait = 1)
192184

193185

194186

@@ -207,17 +199,17 @@
207199
square = 1,
208200
tuplesize = 3,
209201
_with = 'points palette pt 7',
210-
ascii = False)
211-
time.sleep(sleep_interval)
202+
ascii = False,
203+
wait = 1)
212204

213205
# 4d matrix curve
214206
gp.plot(z, x,
215207
title = '4D matrix plot. Binary.',
216208
square = 1,
217209
tuplesize = 4,
218210
_with = 'points palette ps variable pt 7',
219-
ascii = False)
220-
time.sleep(sleep_interval)
211+
ascii = False,
212+
wait = 1)
221213

222214
# Using broadcasting to plot each slice with a different style
223215
gp.plot((np.rollaxis( np.dstack((x,z)), 2,0),
@@ -226,27 +218,27 @@
226218

227219
title = 'Two 3D matrix plots. Binary.',
228220
square = 1,
229-
ascii = False)
230-
time.sleep(sleep_interval)
221+
ascii = False,
222+
wait = 1)
231223

232224
# # Gnuplot doesn't support this
233225
# gp.plot(z, x,
234226
# title = '4D matrix plot. Binary.',
235227
# square = 1,
236228
# tuplesize = 4,
237229
# _with = 'points palette ps variable pt 7',
238-
# ascii = True)
239-
# time.sleep(sleep_interval)
240-
230+
# ascii = True,
231+
# wait = 1)
232+
#
241233
# 2 3d matrix curves
242234
gp.plot((np.rollaxis( np.dstack((x,z)), 2,0),
243235
{'tuplesize': 3,
244236
'with': np.array(('points palette pt 7','points ps variable pt 6'))}),
245237

246238
title = 'Two 3D matrix plots. Binary.',
247239
square = 1,
248-
ascii = True)
249-
time.sleep(sleep_interval)
240+
ascii = True,
241+
wait = 1)
250242

251243
###################################
252244
# fancy contours just because I can
@@ -267,8 +259,8 @@
267259
'unset grid',
268260
'unset surface',
269261
'set view 0,0'],
270-
square = 1 )
271-
time.sleep(sleep_interval)
262+
square = 1,
263+
wait = 1)
272264

273265

274266
################################

0 commit comments

Comments
 (0)