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
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.
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.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file rang-0.2.0.tar.gz.
File metadata
- Download URL: rang-0.2.0.tar.gz
- Upload date:
- Size: 10.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e745bce5f36bf333f8c702360fd48db1302849e25545d0f793015f1bf0d260ab
|
|
| MD5 |
888cfd0fdcb79f68701af4e84eecb821
|
|
| BLAKE2b-256 |
43a3a5a2768afdb5ad040441210aa28664d812ed0b2f688da558435b248122c1
|
File details
Details for the file rang-0.2.0-py3-none-any.whl.
File metadata
- Download URL: rang-0.2.0-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/7.0.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9c8b10b93ae5a8931af5b28f68c5533ebd3c629ee05a25e8074e48d0dfe693fc
|
|
| MD5 |
7f2c22bfa3802868f381eccc25f13d1b
|
|
| BLAKE2b-256 |
cf63b3283329a67ea59697f98fcc1843f70455c574e4403b043f9fccf9077453
|