Cycle¶
- Cycle(*args, N=None, samples=None, name=None, **kwargs)[source]¶
Generate and merge
Cycler
instances in a variety of ways.- Parameters
*args (
colormap-spec
orcycle-spec
, optional) – Positional arguments control the colors in theCycler
object. If zero arguments are passed, the single color'black'
is used. 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 sequence of RGB tuples or color strings, these colors are used.
If a
DiscreteColormap
, colors from thecolors
attribute are used.If a string cycle name, that
DiscreteColormap
is looked up and itscolors
are used.In all other cases, the argument is passed to
Colormap
, and colors from the resultingContinuousColormap
are used. See thesamples
argument.
If the last positional argument is numeric, it is used for the
samples
keyword argument.N – Shorthand for
samples
.samples (
float
or sequence offloat
, optional) – ForDiscreteColormap
s, this is the number of colors to select. For example,Cycle('538', 4)
returns the first 4 colors of the'538'
color cycle. ForContinuousColormap
s, this is either a sequence of sample coordinates used to draw colors from the colormap, 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.
- Other Parameters
c, color, colors (sequence of
color-spec
, optional) – A sequence of colors passed as keyword arguments. This is equivalent to passing a sequence of colors as the first positional argument and is included for consistency withset_prop_cycle
. If positional arguments were passed, the colors in this list are appended to the colors resulting from the positional arguments.lw, ls, d, a, m, ms, mew, mec, mfc – Shorthands for the below keywords.
linewidth, linestyle, dashes, alpha, marker, markersize, markeredgewidth, markeredgecolor, markerfacecolor (
object
or sequence ofobject
, optional) – Lists ofLine2D
properties that can be added to theCycler
instance. If the input was already aCycler
, these are added or appended to the existing cycle keys. If the lists have unequal length, they are repeated to their least common multiple (note that matplotlib throws an error in this case). For more info on cyclers seeset_prop_cycle
. 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.
**kwargs – If the input is not already a
Cycler
instance, these are passed toColormap
and used to build theDiscreteColormap
from which the cycler will draw its colors.
- Returns
Cycler
– A cycler instance that can be passed toset_prop_cycle
.
See also