@@ -76,21 +76,6 @@ the function provides a simple interface for creating 'base' `Cycler` objects.
7676
7777A 'base' `Cycler ` object is some what useful
7878
79- .. ipython :: python
80-
81- from matplotlib.cycler import cycler
82-
83-
84- single_cycle = cycler(' c' , [' r' , ' g' , ' b' ])
85-
86- print (single_cycle)
87-
88- for v in single_cycle:
89- print (v)
90-
91- len (single_cycle)
92-
93-
9479.. plot ::
9580 :include-source:
9681
@@ -109,46 +94,74 @@ A 'base' `Cycler` object is some what useful
10994 for i, sty in zip(range(1, 10), cycle(single_cycle)):
11095 ax2.plot(x, x*i, **sty)
11196
112- However they are most useful when composed. They can be added
11397
11498.. ipython :: python
11599
116100 from __future__ import print_function
117101 from matplotlib.cycler import cycler
118102
103+
119104 color_cycle = cycler(' c' , [' r' , ' g' , ' b' ])
105+
106+ color_cycle
107+
108+ for v in color_cycle:
109+ print (v)
110+
111+ len (color_cycle)
112+
113+
114+
115+ However they are most useful when composed. They can be added
116+
117+ .. ipython :: python
118+
120119 lw_cycle = cycler(' lw' , range (1 , 5 ))
121120 add_cycle = color_cycle + lw_cycle
122121
123- print (color_cycle)
124- print (lw_cycle)
125- print (' added cycle: ' , add_cycle)
126-
127- print (' len A: {} , len B: {} , len A + B: {} ' .format(len (color_cycle), len (lw_cycle), len (add_cycle)))
122+ lw_cycle
123+ add_cycle
128124
129125 for v in add_cycle:
130126 print (v)
131127
128+ len (add_cycle)
129+
132130 or multiplied
133131
134132.. ipython :: python
135133
136- from __future__ import print_function
137- from matplotlib.cycler import cycler
138-
139- color_cycle = cycler(' c' , [' r' , ' g' , ' b' ])
140- lw_cycle = cycler(' lw' , range (1 , 5 ))
141-
142134 prod_cycle = color_cycle * lw_cycle
143135
144- print (color_cycle)
145- print (lw_cycle)
146- print (' multiplied cycle: ' , prod_cycle)
147-
148- print (' len A: {} , len B: {} , len A * B: {} ' .format(len (color_cycle), len (lw_cycle), len (prod_cycle)))
136+ color_cycle
137+ lw_cycle
138+ prod_cycle
149139
150140 for v in prod_cycle:
151141 print (v)
152142
143+ len (prod_cycle)
144+
145+ The result of composition is another `Cycler ` object which allows very
146+ complicated cycles to be defined very succinctly
153147
154- stuff
148+ .. ipython :: python
149+
150+
151+ .. plot ::
152+ :include-source:
153+
154+ from matplotlib.cycler import cycler
155+ from itertools import cycle
156+
157+ fig, (ax1, ax2) = plt.subplots(1, 2, tight_layout=True, figsize=(8, 4))
158+ x = np.arange(10)
159+
160+ single_cycle = cycler('c', ['r', 'g', 'b'])
161+
162+ for i, sty in enumerate(single_cycle):
163+ ax1.plot(x, x*(i+1), **sty)
164+
165+
166+ for i, sty in zip(range(1, 10), cycle(single_cycle)):
167+ ax2.plot(x, x*i, **sty)
0 commit comments