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 or cycle-spec, optional) – Positional arguments control the colors in the Cycler 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 the colors attribute are used.

    • If a string cycle name, that DiscreteColormap is looked up and its colors are used.

    • In all other cases, the argument is passed to Colormap, and colors from the resulting ContinuousColormap are used. See the samples argument.

    If the last positional argument is numeric, it is used for the samples keyword argument.

  • N – Shorthand for samples.

  • samples (float or sequence of float, optional) – For DiscreteColormaps, this is the number of colors to select. For example, Cycle('538', 4) returns the first 4 colors of the '538' color cycle. For ContinuousColormaps, 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 are np.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 with set_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 of object, optional) – Lists of Line2D properties that can be added to the Cycler instance. If the input was already a Cycler, these are added or appended to the existing cycle keys. If the lists have unequal length, they are repeated to their least common multiple (unlike cycler, which throws an error in this case). For more info on cyclers see set_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 to Colormap and used to build the DiscreteColormap from which the cycler will draw its colors.

Returns

cycler.Cycler – A Cycler instance that can be passed to set_prop_cycle.