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 package and its documentation follow his technical notes1, 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 maps, etc. All colorsets are given as named tuples. You can then access the colors by index or by name:

>>> import tol_colors as tc
>>> cset = tc.bright
>>> cset.blue
'#4477AA'

Each colorset is available as a module attribute (tc.bright) or in the dictionary tol_colors.colorsets. This is a special mapping that will accept 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. Discrete variants are available by adding "_discrete" to the colormap name (eg tc.sunset_discrete).

The iridescent colormap is meant to be used interpolated; you can still use tc.iridescent.resampled(N) to obtain a discrete version. To obtain a discrete rainbow colormap, use tc.rainbow_discrete(n_colors=14) with a number between 1 and 23.

Colormaps are available either:

  • as module attributes (tc.sunset),
  • stored in a dictionary (tc.colormaps["sunset"]) which returns copies,
  • registered in matplotlib with the prefix "tol." (plt.imshow(..., cmap="tol.sunset")).

Reversed variants are available by appending "_r" to the colormap name.

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.2.0.tar.gz (1.9 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

tol_colors-2.2.0-py3-none-any.whl (12.9 kB view details)

Uploaded Python 3

File details

Details for the file tol_colors-2.2.0.tar.gz.

File metadata

  • Download URL: tol_colors-2.2.0.tar.gz
  • Upload date:
  • Size: 1.9 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tol_colors-2.2.0.tar.gz
Algorithm Hash digest
SHA256 212ff02e2fcf5c7f9cdb928ba1701bcfbf7fe7a24c52a838488e1db398115db6
MD5 32a80717d5b922cd69ba618d97c15f1a
BLAKE2b-256 2a18c4877a3dfd90a7350da789fb3e23f2a0a711eb13d56f3c9f6ce1aa9876b9

See more details on using hashes here.

Provenance

The following attestation bundles were made for tol_colors-2.2.0.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.2.0-py3-none-any.whl.

File metadata

  • Download URL: tol_colors-2.2.0-py3-none-any.whl
  • Upload date:
  • Size: 12.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for tol_colors-2.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f9a13efbbdc9469ee73a4b497c2e7b2acd7e36ad78cfa5a227c1589826ae74f5
MD5 a805b6ba6ac6fb6e317dd0aee07d1d51
BLAKE2b-256 b671113f6baf45953f214f7de1a3cc1494fb0289641a93adc42ba78eaec5c513

See more details on using hashes here.

Provenance

The following attestation bundles were made for tol_colors-2.2.0-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 Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page