Skip to content

Commit 49a04ae

Browse files
committed
demo: slightly nicer syntax
1 parent 57fe5c4 commit 49a04ae

File tree

1 file changed

+23
-22
lines changed

1 file changed

+23
-22
lines changed

demo.py

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -67,10 +67,10 @@ def check_expected_error(what, f):
6767
wait=1)
6868
gp.plot(-x, x**3, wait=1)
6969
gp.plot((x**2), wait=1)
70-
gp.plot((-x, x**3, {'with': 'lines'}), (x**2,), wait=1)
70+
gp.plot((-x, x**3, dict(_with = 'lines')), (x**2,), wait=1)
7171
gp.plot( x, np.vstack((x**3, x**2)) , wait=1)
7272
gp.plot( np.vstack((-x**3, x**2)), _with='lines' , wait=1)
73-
gp.plot( (np.vstack((x**3, -x**2)), {'with': 'points'} ), wait=1)
73+
gp.plot( (np.vstack((x**3, -x**2)), dict(_with = 'points') ), wait=1)
7474

7575
# Make sure xrange settings don't get overridden. The label below should be out
7676
# of bounds, and not visible
@@ -100,18 +100,18 @@ def check_expected_error(what, f):
100100
wait = 1)
101101

102102
plot1.plot( ( np.vstack((x, x*2, x*3)), x**2 - 300,
103-
{'with': 'lines lw 4',
104-
'y2': True,
105-
'legend': 'parabolas'}),
103+
dict(_with = 'lines lw 4',
104+
y2 = True,
105+
legend = 'parabolas')),
106106

107107
(x**2 * 10, x**2/40, x**2/2, # implicit domain
108-
{'with': 'xyerrorbars',
109-
'tuplesize': 4}),
108+
dict(_with = 'xyerrorbars',
109+
tuplesize = 4)),
110110

111111
(x, np.vstack((x**3, x**3 - 100)),
112-
{"with": 'lines',
113-
'legend': 'shifted cubics',
114-
'tuplesize': 2}))
112+
dict(_with = 'lines',
113+
legend = 'shifted cubics',
114+
tuplesize = 2)))
115115

116116
#################################
117117

@@ -186,9 +186,9 @@ def check_expected_error(what, f):
186186
# some paraboloids plotted on an implicit 2D domain
187187
xx,yy = np.ogrid[-10:11, -10:11]
188188
zz = xx*xx + yy*yy
189-
gp.plot3d( ( zz, {'legend': 'zplus'}),
190-
(-zz, {'legend': 'zminus'}),
191-
(zz*2, {'legend': 'zplus2'}),
189+
gp.plot3d( ( zz, dict(legend = 'zplus')),
190+
(-zz, dict(legend = 'zminus')),
191+
(zz*2, dict(legend = 'zplus2')),
192192

193193
_with = 'points', title = 'gridded paraboloids', ascii=True,
194194
wait = 1)
@@ -222,12 +222,12 @@ def check_expected_error(what, f):
222222
xx,yy = np.ogrid[-10:11, -10:11]
223223
zz = xx*xx + yy*yy
224224
xx = np.linspace(0,20,100)
225-
gp.plot( ( zz, {'tuplesize': 3,
226-
'with': 'image'}),
225+
gp.plot( ( zz, dict(tuplesize = 3,
226+
_with = 'image')),
227227
(xx, 20*np.cos(xx/20 * np.pi/2),
228228

229-
{'tuplesize': 2,
230-
'with': 'lines'}),
229+
dict(tuplesize = 2,
230+
_with = 'lines')),
231231

232232
title = 'Paraboloid heat map, 2D',
233233
xmin = 0,
@@ -267,8 +267,8 @@ def check_expected_error(what, f):
267267

268268
# Using broadcasting to plot each slice with a different style
269269
gp.plot((np.rollaxis( np.dstack((xx,zz)), 2,0),
270-
{'tuplesize': 3,
271-
'with': np.array(('points palette pt 7','points ps variable pt 6'))}),
270+
dict(tuplesize = 3,
271+
_with = np.array(('points palette pt 7','points ps variable pt 6')))),
272272

273273
title = 'Two 3D matrix plots. Binary.',
274274
square = 1,
@@ -286,8 +286,8 @@ def check_expected_error(what, f):
286286
#
287287
# 2 3d matrix curves
288288
gp.plot((np.rollaxis( np.dstack((xx,zz)), 2,0),
289-
{'tuplesize': 3,
290-
'with': np.array(('points palette pt 7','points ps variable pt 6'))}),
289+
dict(tuplesize = 3,
290+
_with = np.array(('points palette pt 7','points ps variable pt 6')))),
291291

292292
title = 'Two 3D matrix plots. Binary.',
293293
square = 1,
@@ -304,7 +304,8 @@ def check_expected_error(what, f):
304304

305305
# single 3d matrix curve. Two plots: the image and the contours together.
306306
# Broadcasting the styles
307-
gp.plot3d( (zz, {'tuplesize': 3, 'with': np.array(('image','lines'))}),
307+
gp.plot3d( (zz, dict(tuplesize = 3,
308+
_with = np.array(('image','lines')))),
308309

309310
title = 'matrix plot with contours',
310311
cmds = [ 'set contours base',

0 commit comments

Comments
 (0)