Skip to main content

rang for Python

Color palettes from Persian art. Part of the Rang project, which also packages the palettes for R, ArcGIS Pro, QGIS, GeoLibre and HEC-RAS.

pip install rang

The package has no required dependencies. The matplotlib helpers need matplotlib, which you can pull in at the same time:

pip install "rang[plots]"

Colors

import rang

rang.list_palettes()                      # available names
rang.rang("Kashan")                       # all nine colors, ramp order
rang.rang("Kashan", 4)                    # four well separated colors
rang.rang("Kashan", 30, "continuous")     # interpolated ramp
rang.source("Kashan")                     # the artwork behind the palette
rang.rang("Rasht")                        # nine colors from Municipality Square

Discrete requests use the stored separation order. Continuous requests interpolate through the source ramp in sRGB.

matplotlib

rang.cmap("Termeh")           # smooth colormap
rang.cmap("Termeh", 6)        # six fixed steps, for classified data
rang.cmap("Termeh", direction=-1)   # reversed

rang.set_palette("Golestan")  # default colors for lines and bars

register() adds every palette to the matplotlib registry under a rang: name. Do this once and any library that accepts a colormap name will take a Rang palette, including xarray, geopandas, rioxarray and seaborn.

rang.register()

plt.imshow(data, cmap="rang:Iwan")
plt.imshow(data, cmap="rang:Iwan_r")      # every palette also registers reversed

Calling register() again is safe and quiet.

Picking a palette

Termeh, Iwan, Khatam and Rostan run steadily from light to dark or dark to light, which is what depth, elevation and rainfall maps need. Kashan, Golestan and Mina move from a warm side through a light center to a cool side. Nasir, Shahnameh and Gilas jump around in brightness, so they suit categories rather than measured quantities.

Rasht groups two blues, adjacent red and orange, and two greens in a ramp that runs broadly from dark violet to pale lilac. It suits categories and classified maps. Inspect a continuous map before using the full ramp for a measured quantity.

Each palette page in the repository shows sample plots and the color vision checks.

License

The package software is available under the MIT License. To the extent that copyright or database rights apply, the Rang palette definitions are dedicated to the public domain under CC0 1.0 Universal. Photographs and third-party data are covered by the notices in the main repository.

Metadata

Release files for rang 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for rang 0.3.0
File Size Uploaded
rang-0.3.0.tar.gz 11.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rang 0.3.0
File Interpreter ABI Platform
rang-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 21.5 kB

Release files / rang-0.3.0.tar.gz

Download URL rang-0.3.0.tar.gz
Size 11.1 kB
Tags Source
SHA-256 checksum
How to use checksums
4c9f0064e81f1d5b3eeab0a94375f13504e224273c3e9043f1a1017eb3198869
BLAKE2b-256 checksum
How to use checksums
5b47ff06de9865067070781cba94e765cc4d7f69ad850288d8e4cd1ae490904e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 15, 2026.

Transparency log

Release files / rang-0.3.0-py3-none-any.whl

Download URL rang-0.3.0-py3-none-any.whl
Size 10.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5f98cfe194b0448e848d7bd3dd04bd38dd68555732ddd9190747dede595f7dba
BLAKE2b-256 checksum
How to use checksums
de706881c82c463a9236a62072f99b1523834116c774cab80f3fa8ccca6ba21a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Sep 15, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page