Cycler

0.12.1 · active · verified Sat Mar 28

Cycler is a Python library for creating composable style cycles, allowing for flexible and reusable combinations of style properties. The current version is 0.12.1, released on a regular basis, with the latest release on March 28, 2026.

Warnings

Install

Imports

Quickstart

This example demonstrates how to use Cycler to create a custom style cycle for plotting multiple sine curves with different colors and line styles.

from cycler import cycler
import matplotlib.pyplot as plt
import numpy as np

# Generate sample data
x = np.linspace(0, 2 * np.pi, 50)
offsets = np.linspace(0, 2 * np.pi, 4, endpoint=False)
yy = np.transpose([np.sin(x + phi) for phi in offsets])

# Create a cycler object
style_cycler = cycler(color=['r', 'g', 'b', 'c'], linestyle=['-', '--', '-.'])

# Apply the cycler to the current axes
plt.gca().set_prop_cycle(style_cycler)

# Plot the data
for y in yy:
    plt.plot(x, y)

plt.show()

view raw JSON →