Cycle¶
-
Cycle
(*args, samples=None, name=None, marker=None, alpha=None, dashes=None, linestyle=None, linewidth=None, markersize=None, markeredgewidth=None, markeredgecolor=None, markerfacecolor=None, save=False, save_kw=None, **kwargs)[source]¶ Generate and merge
Cycler
instances in a variety of ways. Used to interpret thecycle
andcycle_kw
arguments when passed to any plotting method wrapped bycycle_changer
.If you just want a list of colors instead of a
Cycler
instance, use thecolors
function. If you want aCycler
instance that imposes black as the default color and cycles through properties likelinestyle
instead, call this function without any positional arguments.- Parameters
*args (colormap-spec or cycle-spec, optional) – Positional arguments control the colors in the
Cycler
object. If more than one argument is passed, the resulting cycles are merged. Arguments are interpreted as follows.If
Cycler
, nothing more is done.If list of RGB tuples or color strings, these colors are used.
If
ListedColormap
, colors from thecolors
attribute are used.If string color cycle name, that
ListedColormap
is looked up and itscolors
attribute is used. Seecycles
.Otherwise, the argument is passed to
Colormap
, and colors from the resultingLinearSegmentedColormap
are used. See thesamples
argument.
If the last positional argument is numeric, it is used for the
samples
keyword argument.samples (float or list of float, optional) – For
ListedColormap
s, this is the number of colors to select. For example,Cycle('538', 4)
returns the first 4 colors of the'538'
color cycle.For
LinearSegmentedColormap
s, 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.name (str, optional) – Name of the resulting
ListedColormap
used to register the color cycle. Default name is'no_name'
.marker, alpha, dashes, linestyle, linewidth, markersize, markeredgewidth, markeredgecolor, markerfacecolor (list of specs, optional) – Lists of
Line2D
properties that can be added to theCycler
instance. If the lists have unequal length, they will be filled to match the length of the longest list. Seeset_prop_cycle
for more info on cyclers. Also see the line style reference, the marker reference, and the custom dashes reference.save (bool, optional) – Whether to save the
ListedColormap
associated with this cycle. SeeListedColormap.save
.save_kw (dict-like, optional) – Ignored if
save
isFalse
. Passed toListedColormap.save
for theListedColormap
associated with this cycle.**kwargs – Passed to
Colormap
when the input is not already aCycler
instance.
- Returns
Cycler
– A cycler instance that can be passed toset_prop_cycle
.