Skip to main content

A pigment-inspired colour palette for reading and code, rooted in Moby-Dick.

Project description

pequod · Python package

The Pequod palette for Python: the full Log base scale, eight crew accents (light and dark variants), and matplotlib helpers.

The narrative, design rationale, and full accessibility analysis live in the repository README and on the project website.

Install

From PyPI:

pip install pequod

With the matplotlib helpers:

pip install "pequod[plot]"

From source (the Python package lives in the python/ subdirectory of the main repository):

pip install "git+https://github.com/tiagojct/pequod.git#subdirectory=python"

Quick start

from pequod import LOG, CREW_LIGHT, CREW_DARK, palette

LOG                       # 12-step Log base scale, dict[str, str]
CREW_LIGHT                # 8 accents, light variants
CREW_DARK                 # 8 accents, dark variants

palette("log")            # full Log scale, list[str] of hex codes
palette("crew", n=5)      # first five crew accents
palette("log-cool", n=100, kind="continuous")    # interpolated to 100

Six named palettes:

Name Length Kind Suggested use
log 12 sequential continuous gradients, heatmaps
log-warm 6 sequential warm side only (Log 50–400)
log-cool 6 sequential cool side only (Log 500–950)
crew 8 qualitative categories, groups (light variants)
crew-dark 8 qualitative categories on a dark theme
syntax 8 qualitative crew in syntax-role order

Matplotlib

Two surfaces, depending on how much ceremony you want.

Register all palettes once, then use by name:

import matplotlib.pyplot as plt
import numpy as np
import pequod

pequod.register_cmaps()    # adds pequod_log, pequod_crew, etc.

x = np.outer(np.linspace(0, 1, 200), np.ones(50))
plt.imshow(x, cmap="pequod_log")
plt.show()

Build a colormap explicitly:

from pequod import to_cmap

cmap = to_cmap("log", kind="continuous")        # LinearSegmentedColormap
cmap = to_cmap("crew", kind="discrete")          # ListedColormap
cmap = to_cmap("log-cool", reverse=True)         # reversed

to_cmap and register_cmaps raise a clear ImportError if matplotlib isn't installed; everything else in the package (the data dicts, palette()) is pure Python with no dependencies.

Keeping tokens in sync

The canonical palette lives at ../pequod.json (one directory above this package). The data shipped with the Python package is generated from it:

cd python
python data-raw/generate_data.py

That rewrites src/pequod/_data.py so the Python values always match the JSON tokens.

Licence

MIT. The underlying palette tokens are also available under CC-BY-4.0 via ../pequod.json; see ../LICENSE-CC-BY-4.0.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pequod-0.1.0.tar.gz (8.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pequod-0.1.0-py3-none-any.whl (8.4 kB view details)

Uploaded Python 3

File details

Details for the file pequod-0.1.0.tar.gz.

File metadata

  • Download URL: pequod-0.1.0.tar.gz
  • Upload date:
  • Size: 8.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for pequod-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9c0ac9ae4d27a1afafe3b80a2bf77ff771801020ce13474ecbe71a42062e4137
MD5 da4c5e4f9d4b962fc8e4f85e290f78ec
BLAKE2b-256 c64fe335e2ff687087d5879e94fc55ecf648aaea483a8fbc6a38a9d1168af678

See more details on using hashes here.

File details

Details for the file pequod-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: pequod-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.4

File hashes

Hashes for pequod-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0363da7666fb4fce5360f22a8cb25ed997a09d9ce666191132bb31a0e87f3ad0
MD5 e38a39d6ac2777baecef0e4b411217a7
BLAKE2b-256 5d1c31bec7d9c6e9c0484ff744f428d82b5620d2a541a40c5f10c2cf30b3b1bb

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page