matplotlib.axes.Axes.set_prop_cycle#

Axes.set_prop_cycle(*args,**kwargs)[source]#

Set the property cycle of the Axes.

The property cycle controls the style properties such as color,marker and linestyle of future plot commands. The style propertiesof data already added to the Axes are not modified.

Call signatures:

set_prop_cycle(cycler)set_prop_cycle(label=values,label2=values2,...)set_prop_cycle(label,values)

Form 1 sets givenCycler object.

Form 2 creates aCycler which cycles over one or moreproperties simultaneously and set it as the property cycle of theAxes. If multiple properties are given, their value lists must havethe same length. This is just a shortcut for explicitly creating acycler and passing it to the function, i.e. it's short forset_prop_cycle(cycler(label=values,label2=values2,...)).

Form 3 creates aCycler for a single property and set itas the property cycle of the Axes. This form exists for compatibilitywith the originalcycler.cycler interface. Its use is discouragedin favor of the kwarg form, i.e.set_prop_cycle(label=values).

Parameters:
cyclerCycler orNone

Set the given Cycler.None resets to the cycle defined by thecurrent style.

labelstr

The property key. Must be a validArtist property.For example, 'color' or 'linestyle'. Aliases are allowed,such as 'c' for 'color' and 'lw' for 'linewidth'.

valuesiterable

Finite-length iterable of the property values. These valuesare validated and will raise a ValueError if invalid.

See also

matplotlib.rcsetup.cycler

Convenience function for creating validated cyclers for properties.

cycler.cycler

The original function for creating unvalidated cyclers.

Examples

Setting the property cycle for a single property:

>>>ax.set_prop_cycle(color=['red','green','blue'])

Setting the property cycle for simultaneously cycling over multipleproperties (e.g. red circle, green plus, blue cross):

>>>ax.set_prop_cycle(color=['red','green','blue'],...marker=['o','+','x'])

Examples usingmatplotlib.axes.Axes.set_prop_cycle#

Stock prices over 32 years

Stock prices over 32 years

Styling with cycler

Styling with cycler