Skip to content

Commit db04bff

Browse files
committed
demo.py: varaible rename
I'd like to reuse some of these in later tests, so I don't want to clobber them
1 parent 14bd255 commit db04bff

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

demo.py

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -130,24 +130,24 @@
130130

131131

132132
# some paraboloids plotted on an implicit 2D domain
133-
x,y = np.ogrid[-10:11, -10:11]
134-
z = x*x + y*y
135-
gp.plot3d( ( z, {'legend': 'zplus'}),
136-
(-z, {'legend': 'zminus'}),
137-
(z*2, {'legend': 'zplus2'}),
133+
xx,yy = np.ogrid[-10:11, -10:11]
134+
zz = xx*xx + yy*yy
135+
gp.plot3d( ( zz, {'legend': 'zplus'}),
136+
(-zz, {'legend': 'zminus'}),
137+
(zz*2, {'legend': 'zplus2'}),
138138

139139
_with = 'points', title = 'gridded paraboloids', ascii=True,
140140
wait = 1)
141141

142142
# 3d, variable color, variable pointsize
143-
th = np.linspace(0, 6*np.pi, 200)
144-
z = np.linspace(0, 5, 200)
145-
size = 0.5 + np.abs(np.cos(th))
146-
color = np.sin(2*th)
143+
th2 = np.linspace(0, 6*np.pi, 200)
144+
zz = np.linspace(0, 5, 200)
145+
size = 0.5 + np.abs(np.cos(th2))
146+
color = np.sin(2*th2)
147147

148-
gp.plot3d( ( np.cos(th) * np.array([[1,-1]]).T,
149-
np.sin(th) * np.array([[1,-1]]).T,
150-
z, size, color, { 'legend': np.array(('spiral 1', 'spiral 2'))}),
148+
gp.plot3d( ( np.cos(th2) * np.array([[1,-1]]).T,
149+
np.sin(th2) * np.array([[1,-1]]).T,
150+
zz, size, color, { 'legend': np.array(('spiral 1', 'spiral 2'))}),
151151

152152
title = 'double helix',
153153
tuplesize = 5,
@@ -156,21 +156,21 @@
156156

157157

158158
# implicit domain heat map
159-
x,y = np.ogrid[-10:11, -10:11]
160-
z = x*x + y*y
161-
gp.plot3d(z,
159+
xx,yy = np.ogrid[-10:11, -10:11]
160+
zz = xx*xx + yy*yy
161+
gp.plot3d(zz,
162162
title = 'Paraboloid heat map',
163163
set = 'view map',
164164
_with = 'image',
165165
wait = 1)
166166

167167
# same, but as a 2d gp.plot, _with a curve drawn on top for good measure
168-
x,y = np.ogrid[-10:11, -10:11]
169-
z = x*x + y*y
170-
x = np.linspace(0,20,100)
171-
gp.plot( ( z, {'tuplesize': 3,
168+
xx,yy = np.ogrid[-10:11, -10:11]
169+
zz = xx*xx + yy*yy
170+
xx = np.linspace(0,20,100)
171+
gp.plot( ( zz, {'tuplesize': 3,
172172
'with': 'image'}),
173-
(x, 20*np.cos(x/20 * np.pi/2),
173+
(xx, 20*np.cos(xx/20 * np.pi/2),
174174

175175
{'tuplesize': 2,
176176
'with': 'lines'}),
@@ -187,14 +187,14 @@
187187
################################
188188
# 2D implicit domain demos
189189
################################
190-
x,y = np.mgrid[-10:11, -10:11]
191-
z = np.sqrt(x*x + y*y)
190+
xx,yy = np.mgrid[-10:11, -10:11]
191+
zz = np.sqrt(xx*xx + yy*yy)
192192

193-
x = x[:, 2:12]
194-
z = z[:, 2:12]
193+
xx = xx[:, 2:12]
194+
zz = zz[:, 2:12]
195195

196196
# single 3d matrix curve
197-
gp.plot(z,
197+
gp.plot(zz,
198198
title = 'Single 3D matrix plot. Binary.',
199199
square = 1,
200200
tuplesize = 3,
@@ -203,7 +203,7 @@
203203
wait = 1)
204204

205205
# 4d matrix curve
206-
gp.plot(z, x,
206+
gp.plot(zz, xx,
207207
title = '4D matrix plot. Binary.',
208208
square = 1,
209209
tuplesize = 4,
@@ -212,7 +212,7 @@
212212
wait = 1)
213213

214214
# Using broadcasting to plot each slice with a different style
215-
gp.plot((np.rollaxis( np.dstack((x,z)), 2,0),
215+
gp.plot((np.rollaxis( np.dstack((xx,zz)), 2,0),
216216
{'tuplesize': 3,
217217
'with': np.array(('points palette pt 7','points ps variable pt 6'))}),
218218

@@ -231,7 +231,7 @@
231231
# wait = 1)
232232
#
233233
# 2 3d matrix curves
234-
gp.plot((np.rollaxis( np.dstack((x,z)), 2,0),
234+
gp.plot((np.rollaxis( np.dstack((xx,zz)), 2,0),
235235
{'tuplesize': 3,
236236
'with': np.array(('points palette pt 7','points ps variable pt 6'))}),
237237

@@ -243,14 +243,14 @@
243243
###################################
244244
# fancy contours just because I can
245245
###################################
246-
y,x = np.mgrid[0:61,0:61]
247-
x -= 30
248-
y -= 30
249-
z = np.sin(x / 4.0) * y
246+
yy,xx = np.mgrid[0:61,0:61]
247+
xx -= 30
248+
yy -= 30
249+
zz = np.sin(xx / 4.0) * yy
250250

251251
# single 3d matrix curve. Two plots: the image and the contours together.
252252
# Broadcasting the styles
253-
gp.plot3d( (z, {'tuplesize': 3, 'with': np.array(('image','lines'))}),
253+
gp.plot3d( (zz, {'tuplesize': 3, 'with': np.array(('image','lines'))}),
254254

255255
title = 'matrix plot with contours',
256256
cmds = [ 'set contours base',

0 commit comments

Comments
 (0)