File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -245,6 +245,34 @@ We can use `Cycler` instances to cycle over one or more ``kwarg`` to
245
245
ax2.plot(x, x*(i+1), **sty)
246
246
247
247
248
+ Persistent Cycles
249
+ -----------------
250
+
251
+ It can be useful to associate a given label with a style via
252
+ dictionary lookup and to dynamically generate that mapping. This
253
+ can easily be accomplished using a `~collections.defaultdict `
254
+
255
+ .. ipython :: python
256
+
257
+ from cycler import cycler as cy
258
+ from collections import defaultdict
259
+
260
+ cyl = cy(' c' , ' rgb' ) + cy(' lw' , range (1 , 4 ))
261
+
262
+ To get a finite set of styles
263
+
264
+ .. ipython :: python
265
+
266
+ finite_cy_iter = iter (cyl)
267
+ dd_finite = defaultdict(lambda : next (finite_cy_iter))
268
+
269
+ or repeating
270
+
271
+ .. ipython :: python
272
+
273
+ loop_cy_iter = cyl()
274
+ dd_loop = defaultdict(lambda : next (loop_cy_iter))
275
+
248
276
Exceptions
249
277
----------
250
278
You can’t perform that action at this time.
0 commit comments