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
rang.rang("Confusion", 4)                 # four colors from Negar Ghorbani's portrait

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.

Confusion puts its lightest color in the middle, with warm colors on one side and cool ones on the other. It suits data measured against a normal value, such as precipitation or temperature anomalies. Its pick order keeps the pale middle color out of small discrete sets, since it nearly disappears on a white page.

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.4.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.4.0
File Size Uploaded Provenance Actions
rang-0.4.0.tar.gz 11.7 kB With provenance Details for rang-0.4.0.tar.gz

Built distribution (wheel)

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

Total release size: 22.6 kB

Release files / rang-0.4.0.tar.gz

Download URL rang-0.4.0.tar.gz
Size 11.7 kB
Tags Source
SHA-256 checksum
How to use checksums
10a64e24608a40ff086d043970a743d63d2163222761f01a43ad58498e0ad5a1
BLAKE2b-256 checksum
How to use checksums
16fde680ecb90b08081029acd5cfe6069f544cf818ace8ebdc09eecedc72b1b4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 16, 2026.

Transparency log

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

Download URL rang-0.4.0-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
83a6dcb60015fead050b098e788d6e5d04b9cfddd30b63a75a5fc8de263cc284
BLAKE2b-256 checksum
How to use checksums
9dd7dc9f6b82bb0ef9f12446518ccc0a2c8c501bccf19a223ebebf8188be40a1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 16, 2026.

Transparency log

Security for rang 0.4.0

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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for rang-0.4.0.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 Nov 16, 2026.

Transparency log

A 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.

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