Cycler

raw JSON →
0.12.1 verified Tue May 12 auth: no python install: verified quickstart: stale

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.

pip install cycler
error ModuleNotFoundError: No module named 'cycler'
cause The `cycler` package is not installed in the Python environment, or the environment where it's installed is not the one being used.
fix
Install the cycler library using pip: pip install cycler
error AttributeError: 'Cycler' object has no attribute 'change_key'
cause This error typically occurs when an older version of the `cycler` library is used with a newer version of `matplotlib` that expects a method (`change_key`) which is not present in the older `cycler` version.
fix
Upgrade the cycler library to its latest version: pip install --upgrade cycler
error NameError: name 'cycler' is not defined
cause The `cycler` object or class was used in a context (e.g., `matplotlib.rcParams`) without being explicitly imported from the `cycler` module.
fix
Add from cycler import cycler at the top of your Python script or relevant code block.
error ImportError: cannot import name 'Cycler' from 'cycler'
cause This usually indicates a version mismatch where the `Cycler` class might not be directly exposed at the top level of the `cycler` package in older versions, or there's a conflict with other installed packages.
fix
Ensure cycler is up-to-date: pip install --upgrade cycler. If the issue persists, try importing cycler as a module and accessing its attributes: import cycler then cycler.Cycler().
breaking Cycler 0.12.1 introduces changes to the 'Cycler' class constructor, which may affect existing code that relies on the previous constructor signature.
fix Update the constructor calls to match the new signature as per the latest documentation.
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.
fix Import 'cycler' before importing 'matplotlib.pyplot' to ensure the custom style cycle is applied correctly.
breaking The 'matplotlib' module is not found, preventing the script from importing it. This typically means the package is not installed in the current Python environment.
fix Install the 'matplotlib' package using pip: `pip install matplotlib`
breaking The 'matplotlib' module was not found, leading to a ModuleNotFoundError. This indicates that the 'matplotlib' package is not installed or not available in the current Python environment.
fix Install the 'matplotlib' package using pip: `pip install matplotlib`. Ensure that your environment has all necessary dependencies installed before running the script.
python os / libc status wheel install import disk
3.10 alpine (musl) - - 0.01s 17.8M
3.10 slim (glibc) - - 0.01s 18M
3.11 alpine (musl) - - 0.02s 19.7M
3.11 slim (glibc) - - 0.02s 20M
3.12 alpine (musl) - - 0.01s 11.5M
3.12 slim (glibc) - - 0.01s 12M
3.13 alpine (musl) - - 0.01s 11.2M
3.13 slim (glibc) - - 0.01s 12M
3.9 alpine (musl) - - 0.01s 17.3M
3.9 slim (glibc) - - 0.01s 18M

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()