mplutils.set_color_cycle#
- mplutils.set_color_cycle(*colors, nsteps=7, fig=None)[source]#
Set the color cycle in plots.
Modifies
rcParamsof matplotlib (see here).- Parameters:
- *colors
str, optional Colors seperated by comma and given in HEX-codes.
If no colors are provided, defaults to
OkabeItoPalette(see here for a motivation).Alternatively, the name of a colormap can be specified and the color cycle picks
nstepscolors from that colormap.See matplolib’s colormaps documenation for available colormaps.
- nsteps
int, default 7 Define how many different colors will be set in the color cycler.
Irrelevant if specific colors are passed in colors.
- fig
matplotlib.figure.Figure, optional Optionally, provide a figure. The color cycle of all axes of that figure will be updated.
If None, check if a figure already exists. If so, update the color cycle of all axes of the last active figure.
- *colors
Examples
# Set color cycle to red, green, blue set_color_cycle("#FF0000", "#00FF00", "#0000FF") # Set color cycle to Okabe and Ito palette set_color_cycle() # Set color cycle to a continuous colormap that repeats after 8 colors set_color_cylce(cmap="viridis", nsteps=8) # Set color cycle to a diverging colormap that passes through zero # with the second color set_color_cylce("RdBu", nsteps=3)