Color schemes for lines and maps, color-blind safe
Project description
Tol_colors
Colormaps and qualitative colorsets that are colorblind-safe
Those color schemes were designed by Paul Tol. This repository is packaging his work so that it can be easily installed using pip. This packages and its documentation follow the technical notes of the color schemes1, which are archived in this repository. Details and implementations for other languages can be found on Paul Tols's website.
A more user-friendly documentation is available at https://tol-colors.readthedocs.io, detailing how and when to use the various colorsets and colormaps in this package.
Install
Using pip:
pip install tol-colors
From source:
git clone https://github.com/Descanonge/tol_colors.git
cd tol_colors
pip install .
Show the available colorsets, colormaps, and the discrete rainbow colormap:
python -m tol_colors
Requirements
- numpy
- matplotlib
Discrete/qualitative schemes
Sets of colors that can be used for lines, markers, qualitative lines, etc. All colorsets are given as named tuples. You can then access the colors by index or by name:
>>> cset = tc.bright
>>> cset.blue
'#4477AA'
Each colorset is available as a module attribute (tc.bright
) and stored in the dictionary tol_colors.colorsets
. This is a special mapping that will accepts both hyphen and underscore versions
(tc.colorsets["high-contrast"]
and tc.colorsets["high_contrast"]
will
both work).
This package also provides a function to easily set the default colors used by Matplotlib to one of the colorsets. This will change your matplotlibrc file or a given stylesheet file.
Colormaps
The following colormaps were created by linear interpolation of carefully chosen
colors. Those colors can be used as is for discrete colormaps. These discrete
variants are available by adding "_discrete" to the colormap name (eg
tc.sunset_discrete
). Note the iridescent does not have a readily available
discrete version, and one should use the a dedicated function to obtain a
discrete rainbow.
Colormaps are available as module attributes (tc.sunset
), stored in a
dictionnary tol_colors.colormaps
(tc.colormaps["sunset"]
), and registered in
Matplotlib with the prefix "tol." (plt.imshow(..., cmap="tol.sunset")
).
Reversed variants are available by appending "_r" to the colormap name.
Rather than resampling the interpolated colormaps, discrete rainbow colormap is
available by specifying the number of colors between 1 and 23
(tc.get_colormap("rainbow_discrete", n_colors=14)
).
See also
Other packages already implement these colorschemes and might better suit your needs:
- color_tol
- pyplot-themes
- khroma: R package that includes those schemes
1: Colour Schemes, Paul Tol, SRON/EPS/TN/09-002, issue 3.2, 18 August 2021 ↩
Project details
Release history Release notifications | RSS feed
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
File details
Details for the file tol_colors-2.0.0.post1.tar.gz
.
File metadata
- Download URL: tol_colors-2.0.0.post1.tar.gz
- Upload date:
- Size: 15.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
1d5774de3d15183b2e1dd5014ffef01a93c1195297cc9c019d146e29842fbd7e
|
|
MD5 |
3bb1cc384f19ce756a4932433695380e
|
|
BLAKE2b-256 |
b85f39133a90fbd4b88ba31ece37dcb72446f39f54c066d7885c03eb9b8d0f42
|
Provenance
The following attestation bundles were made for tol_colors-2.0.0.post1.tar.gz
:
Publisher:
pypi-publish.yml
on Descanonge/tol_colors
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
tol_colors-2.0.0.post1.tar.gz
-
Subject digest:
1d5774de3d15183b2e1dd5014ffef01a93c1195297cc9c019d146e29842fbd7e
- Sigstore transparency entry: 220635185
- Sigstore integration time:
-
Permalink:
Descanonge/tol_colors@3087e977d5b55248c4e7b237668e89459bb30aca
-
Branch / Tag:
refs/tags/v2.0.0.post1
- Owner: https://github.com/Descanonge
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
pypi-publish.yml@3087e977d5b55248c4e7b237668e89459bb30aca
-
Trigger Event:
release
-
Statement type:
File details
Details for the file tol_colors-2.0.0.post1-py3-none-any.whl
.
File metadata
- Download URL: tol_colors-2.0.0.post1-py3-none-any.whl
- Upload date:
- Size: 12.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 |
1a17793f78eaccf4fb9d52fc5b97a914fcac9221294bb2569447959eacb9a2d8
|
|
MD5 |
4ddbef4635dd13f3ead839fb1f4d9448
|
|
BLAKE2b-256 |
7f3a3d2dfba2a909a2448f584daca1ba6e480fc2a8c447154412a3d5b780c8dd
|
Provenance
The following attestation bundles were made for tol_colors-2.0.0.post1-py3-none-any.whl
:
Publisher:
pypi-publish.yml
on Descanonge/tol_colors
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1
-
Predicate type:
https://docs.pypi.org/attestations/publish/v1
-
Subject name:
tol_colors-2.0.0.post1-py3-none-any.whl
-
Subject digest:
1a17793f78eaccf4fb9d52fc5b97a914fcac9221294bb2569447959eacb9a2d8
- Sigstore transparency entry: 220635201
- Sigstore integration time:
-
Permalink:
Descanonge/tol_colors@3087e977d5b55248c4e7b237668e89459bb30aca
-
Branch / Tag:
refs/tags/v2.0.0.post1
- Owner: https://github.com/Descanonge
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com
-
Runner Environment:
github-hosted
-
Publication workflow:
pypi-publish.yml@3087e977d5b55248c4e7b237668e89459bb30aca
-
Trigger Event:
release
-
Statement type: