atompy.set_color_cycle#

atompy.set_color_cycle(*colors, nsteps=7, fig=None)[source]#

Set the color cycle in plots.

Modifies rcParams of matplotlib (see here).

Parameters:
*colorsstr, optional

Colors seperated by comma and given in HEX-codes.

If now colors are provided, defaults to Okabe and Ito palette (see here for a motivation).

Alternatively, the name of a colormap can be specified and the color cycle picks nsteps colors from that colormap.

See matplolib’s colormaps documenation for available colormaps.

nstepsint, default 7

Define how many different colors will be set in the color cycler.

Irrelevant if a specific colors are passed in colors.

figmatplotlib.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.

Notes

For some color palettes included in atompy, see Color Palettes.

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)