Cycle¶
- Cycle(*args, N=None, samples=None, name=None, **kwargs)[source]¶
Generate and merge
Cyclerinstances in a variety of ways. Used to interpret thecycleandcycle_kwarguments when passed to any plotting method wrapped byapply_cycle.If you just want a list of colors instead of a
Cyclerinstance, use theColorsfunction. If you want aCyclerinstance that imposes black as the default color and cycles through properties likelinestyleinstead, call this function without any positional arguments.- Parameters
*args (colormap-spec or cycle-spec, optional) – Positional arguments control the colors in the
Cyclerobject. If more than one argument is passed, the resulting cycles are merged. Arguments are interpreted as follows:If a
Cycler, nothing more is done.If a list of RGB tuples or color strings, these colors are used.
If a
ListedColormap, colors from thecolorsattribute are used.If a string cycle name, that
ListedColormapis looked up and itscolorsattribute is used.In all other cases, the argument is passed to
Colormap, and colors from the resultingLinearSegmentedColormapare used. See thesamplesargument.
If the last positional argument is numeric, it is used for the
sampleskeyword argument.N – Shorthand for
samples.samples (float or list of float, optional) – For
ListedColormaps, this is the number of colors to select. For example,Cycle('538', 4)returns the first 4 colors of the'538'color cycle.For
LinearSegmentedColormaps, this is either a list of sample coordinates used to draw colors from the map, or an integer number of colors to draw. If the latter, the sample coordinates arenp.linspace(0, 1, samples). For example,Cycle('Reds', 5)divides the'Reds'colormap into five evenly spaced colors.lw, ls, d, a, m, ms, mew, mec, mfc – Shorthands for the below keywords.
linewidth, linestyle, dashes, alpha, marker, markersize, markeredgewidth, markeredgecolor, markerfacecolor (spec or list of specs, optional) – Lists of
Line2Dproperties that can be added to theCyclerinstance. If the lists have unequal length, they will be filled to match the length of the longest list. Seeset_prop_cyclefor more info on cyclers. Also see the line style reference, the marker reference, and the custom dashes reference.linewidths, linestyles, dashes, alphas, markers, markersizes, markeredgewidths, markeredgecolors, markerfacecolors – Aliases for the above keywords.
- Other Parameters
**kwargs – If the input is not already a
Cyclerinstance, these are passed toColormapand used to build theListedColormapfrom which the cycler will draw its colors.- Returns
Cycler– A cycler instance that can be passed toset_prop_cycle.
See also