Cycler
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
- breaking Cycler 0.12.1 introduces changes to the 'Cycler' class constructor, which may affect existing code that relies on the previous constructor signature.
- gotcha When using Cycler with Matplotlib, ensure that the 'cycler' module is imported before creating plots to avoid potential conflicts with Matplotlib's default style cycle.
Install
-
pip install cycler
Imports
- cycler
from cycler import cycler
- Cycler
from cycler import Cycler
Quickstart
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()