@@ -243,15 +243,18 @@ def test_make_compound_path_stops():
243
243
assert np .sum (compound_path .codes == Path .STOP ) == 0
244
244
245
245
246
+ def test_xkcd_seed_update ():
247
+ with plt .xkcd (seed = 2000 ):
248
+ assert rcParams ['path.sketch_seed' ] == 2000
249
+
250
+
246
251
@image_comparison (['xkcd.png' ], remove_text = True )
247
252
def test_xkcd ():
248
253
np .random .seed (0 )
249
254
250
255
x = np .linspace (0 , 2 * np .pi , 100 )
251
256
y = np .sin (x )
252
- # we should be able to update seed through xkcd or Artist().set_sketch_params
253
- rcParams ['path.sketch_seed' ] = 19680801
254
- with plt .xkcd (seed = 0 ):
257
+ with plt .xkcd ():
255
258
fig , ax = plt .subplots ()
256
259
ax .plot (x , y )
257
260
@@ -264,16 +267,33 @@ def test_xkcd_marker():
264
267
y1 = x
265
268
y2 = 5 - x
266
269
y3 = 2.5 * np .ones (8 )
267
- # we should be able to update seed through xkcd or Artist().set_sketch_params
268
- rcParams ['path.sketch_seed' ] = 19680801
269
270
with plt .xkcd ():
270
- artist .Artist ().set_sketch_params (seed = 0 )
271
271
fig , ax = plt .subplots ()
272
272
ax .plot (x , y1 , '+' , ms = 10 )
273
273
ax .plot (x , y2 , 'o' , ms = 10 )
274
274
ax .plot (x , y3 , '^' , ms = 10 )
275
275
276
276
277
+ @image_comparison (['xkcd_artist.png' ], remove_text = True )
278
+ def test_xkcd_artist ():
279
+ with plt .xkcd ():
280
+ rcParams ['path.sketch' ] = (2 , 120 , 40 )
281
+ artist .Artist ().set_sketch_params (seed = 19680801 )
282
+ pat , txt = plt .pie ([10 , 20 , 30 , 40 ], wedgeprops = {'edgecolor' : 'black' })
283
+ plt .legend (pat , ['first' , 'second' , 'third' , 'fourth' ], loc = 'best' )
284
+ plt .plot ()
285
+
286
+
287
+ @image_comparison (['xkcd_seed.png' ], remove_text = True )
288
+ def test_xkcd_seed ():
289
+ with plt .xkcd ():
290
+ rcParams ['path.sketch' ] = (2 , 120 , 40 )
291
+ rcParams ['path.sketch_seed' ] = 2000
292
+ pat , txt = plt .pie ([10 , 20 , 30 , 40 ], wedgeprops = {'edgecolor' : 'black' })
293
+ plt .legend (pat , ['first' , 'second' , 'third' , 'fourth' ], loc = 'best' )
294
+ plt .plot ()
295
+
296
+
277
297
@image_comparison (['marker_paths.pdf' ], remove_text = True )
278
298
def test_marker_paths_pdf ():
279
299
N = 7
0 commit comments