Skip to main content

Color schemes for lines and maps, color-blind safe

Project description

Tol_colors

Colormaps and qualitative colorsets that are colorblind-safe

PyPI GitHub release Tests Documentation

icon

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

colorsets

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

colorsmaps

See also

Other packages already implement these colorschemes and might better suit your needs:

1: Colour Schemes, Paul Tol, SRON/EPS/TN/09-002, issue 3.2, 18 August 2021

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

tol_colors-2.0.0.post1.tar.gz (15.4 kB view details)

Uploaded Source

Built Distribution

tol_colors-2.0.0.post1-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

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

Hashes for tol_colors-2.0.0.post1.tar.gz
Algorithm Hash digest
SHA256 1d5774de3d15183b2e1dd5014ffef01a93c1195297cc9c019d146e29842fbd7e
MD5 3bb1cc384f19ce756a4932433695380e
BLAKE2b-256 b85f39133a90fbd4b88ba31ece37dcb72446f39f54c066d7885c03eb9b8d0f42

See more details on using hashes here.

Provenance

The following attestation bundles were made for tol_colors-2.0.0.post1.tar.gz:

Publisher: pypi-publish.yml on Descanonge/tol_colors

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file tol_colors-2.0.0.post1-py3-none-any.whl.

File metadata

File hashes

Hashes for tol_colors-2.0.0.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 1a17793f78eaccf4fb9d52fc5b97a914fcac9221294bb2569447959eacb9a2d8
MD5 4ddbef4635dd13f3ead839fb1f4d9448
BLAKE2b-256 7f3a3d2dfba2a909a2448f584daca1ba6e480fc2a8c447154412a3d5b780c8dd

See more details on using hashes here.

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

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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