cubehelix-studio
Cubehelix color palettes that survive grayscale, colorblindness, and print. Zero runtime dependencies; matplotlib integration available behind an optional extra.
Interactive playground: obang.pub/cubehelix-studio — adjust the parameters live in your browser.
Install
pip install cubehelix-studio # core only
pip install "cubehelix-studio[viz]" # with matplotlib adapter
# or with uv:
uv add cubehelix-studio
uv add "cubehelix-studio[viz]"
Usage
from cubehelix_studio import CubehelixParams, cubehelix, sample_sequential, to_hex
# Single point on the curve
mid = cubehelix(0.5, CubehelixParams())
# 9 evenly-spaced samples (endpoints included)
palette = sample_sequential(CubehelixParams(), 9)
[to_hex(c) for c in palette]
# => ['#000000', '#1c1338', ..., '#ffffff']
Matplotlib integration
from cubehelix_studio import CubehelixParams, to_matplotlib_colormap
import matplotlib.pyplot as plt
import numpy as np
cmap = to_matplotlib_colormap(CubehelixParams(rotations=-2.0, saturation=1.2))
plt.imshow(np.random.rand(64, 64), cmap=cmap)
plt.colorbar()
plt.show()
API
CubehelixParams
Frozen dataclass with fields:
start: float = 0.5- starting hue positionrotations: float = -1.5- rotations through the color wheelsaturation: float = 1.0- chromatic amplitudegamma: float = 1.0- gamma correction
Note: matplotlib's
cubehelix_paletteand Dave Green's 2011 paper call thesaturationfieldhue. It controls chromatic amplitude — when zero, the output is a pure greyscale ramp — sosaturationis more accurate.
cubehelix(t, params) -> tuple[float, float, float]
Returns the (r, g, b) triple at fraction t in [0, 1]. Each channel is clamped to [0, 1].
sample_sequential(params, n) -> list[tuple[float, float, float]]
Returns n colors at evenly-spaced positions i / (n - 1). Requires n >= 2.
to_hex(rgb) -> str
Formats an RGB triple as #rrggbb.
to_rgb_255(rgb) -> tuple[int, int, int]
Returns the integer 0-255 form of an RGB triple.
contrast_ratio(a, b) -> float
WCAG 2.1 contrast ratio in [1.0, 21.0].
pick_text_color(bg, candidates=None) -> tuple[float, float, float]
Returns whichever candidate has the highest contrast against bg. Defaults to [white, black].
to_matplotlib_colormap(params, n=256, name="cubehelix_studio")
Returns a matplotlib.colors.LinearSegmentedColormap. Requires the [viz] extra.
Parity with @cubehelix-studio/core
This package's math is verified against the same JSON fixture that the TypeScript reference implementation generates (fixtures/parity.json at the repo root). Both implementations must agree to within 1e-12 per channel for every parameter combination in the fixture.
License
MIT
Metadata
Release files for cubehelix-studio 0.0.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cubehelix_studio-0.0.1.tar.gz | 4.9 kB | With provenance | Details for cubehelix_studio-0.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cubehelix_studio-0.0.1-py3-none-any.whl | Python 3 | none | any | Details for cubehelix_studio-0.0.1-py3-none-any.whl |
Total release size: 11.5 kB
Release files / cubehelix_studio-0.0.1.tar.gz
| Download URL | cubehelix_studio-0.0.1.tar.gz |
|---|---|
| Size | 4.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4d75133e840f8c54e6af37e87e8e02d8c0bf71a1a1aa2c51e8e5b32d81886d36
|
|
BLAKE2b-256 checksum How to use checksums |
091660986eb47d19bdc919894880bf69d8245491b509c33450c97e8bdb70147d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 28, 2026.
Transparency logRelease files / cubehelix_studio-0.0.1-py3-none-any.whl
| Download URL | cubehelix_studio-0.0.1-py3-none-any.whl |
|---|---|
| Size | 6.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1354d2cc1dafe1e5a40de2b7a14ab898929ab3face4b6a20d38b20f2e5623ca3
|
|
BLAKE2b-256 checksum How to use checksums |
81cec4ef56abe76c41c3156210087a73e783e728643b28572e0170418e3de586
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.13
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 28, 2026.
Transparency logSecurity for cubehelix-studio 0.0.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
All 2 files in this release have been uploaded with provenance metadata.
Attestation for cubehelix_studio-0.0.1.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Apr 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.