Skip to main content

Color schemes for Python plots, from Paul Tol (2012)

Project description

cblind

PyPI

A colorblind-friendly python module that allows color choice for plotting multiple curves
Works only with python 3
8 colormaps are now available to map 2D fields
Version: 2.2.4 Author: Gaylor Wafflard-Fernandez
Author-email: gaylor.wafflard@univ-grenoble-alpes.fr

Installation

Install with pip

pip install cblind

To import cblind:

import cblind as cb

Usage for plotting

10 palette functions to plot curves are available for now in the Colorplots class, with the corresponding test plotting functions.

cblind

color, linestyle = cb.Coloplots().cblind(nb_of_plots)

from 1 to 12 plots [DISTINCT COLORS]. For more than 12 plots, the linestyle is changed.

cb.test_cblind(nb_of_plots)

cblind

contrast

color, linestyle = cb.Coloplots().contrast(nb_of_plots)

for less than 4 contrast plots [DISTINCT COLORS]. For more than 12 plots, the linestyle is changed.

cb.test_contrast(nb_of_plots)

contrast

huescale

color, linestyle = cb.Coloplots().huescale(nb_of_plots, *option)

from 1 to 9 plots [SEQUENTIAL DATA]. With option "blue","bluegreen","green", "gold","brown","rose","purple" for less than 3 plots, otherwise ocherscale.

cb.test_huescale(nb_of_plots, *option)

huescale

rbscale

color, linestyle = cb.Coloplots().rbscale(nb_of_plots)

from 3 to 11 plots [DIVERGING DATA].

cb.test_rbscale(nb_of_plots)

rbscale

rainbow

color, linestyle = cb.Coloplots().rainbow(nb_of_plots)

from 4 to 12 plots [RAINBOW SCHEME].

cb.test_rainbow(nb_of_plots)

rainbow

extreme_rainbow

color, linestyle = cb.Coloplots().extreme_rainbow(nb_of_plots)

from 1 to 34 plots [RAINBOW SCHEME].

cb.test_extreme_rainbow(nb_of_plots)

extreme_rainbow

solstice

color, linestyle = cb.Coloplots().solstice(nb_of_plots)

for less than 11 plots [DIVERGING DATA]

cb.test_solstice(nb_of_plots)

solstice

bird

color, linestyle = cb.Coloplots().bird(nb_of_plots)

for less than 9 plots [DIVERGING DATA]

cb.test_bird(nb_of_plots)

bird

pregunta

color, linestyle = cb.Coloplots().pregunta(nb_of_plots)

for less than 9 plots [DIVERGING DATA]

cb.test_pregunta(nb_of_plots)

pregunta

monocolor

color, linestyle = cb.Coloplots().monocolor(nb_of_plots, *option)

from 1 to 13 monochromatic plots [MONOCOLOR/PRINTING] with different linestyles. With option "b&w", "blue", "red", "yellow", "green", "purple".

cb.test_monocolor(nb_of_plots, *option)

monocolor

Usage for colormaps

8 cblind palettes are available for now : "cb.rbscale", "cb.rainbow", "cb.extreme_rainbow", "cb.huescale", "cb.solstice", "cb.bird", "cb.pregunta", "cb.iris", but also all colormaps from matplotlib + "_r" variants for reverse colormaps.

cmap = cb.cbmap(palette, nbin)

The nbin argument is used to discretize the colormaps.

colormaps

To test the colormaps, you can try:

cb.test_mapping(palette, nbin)

Example with a field data2d

import numpy as np
import matplotlib.pyplot as plt
data2d = np.repeat(np.linspace(0,1,100),20).reshape(100,20).T

fig, ax = plt.subplots()
im = ax.imshow(data2d, cmap=cb.cbmap("cb.rainbow_r", nbin=10), aspect='auto')
fig.colorbar(im)
plt.show()

Basic mapping function

cb.mapping(fig,ax,data2d,extent,palette=palette,nbin=nbin)

REFERENCE
Paul Tol. 2012. "Colour Schemes." SRON Technical Note, SRON/EPS/TN/09-002.
https://personal.sron.nl/~pault/data/colourschemes.pdf

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

cblind-2.2.4.tar.gz (222.4 kB view details)

Uploaded Source

Built Distribution

cblind-2.2.4-py3-none-any.whl (20.5 kB view details)

Uploaded Python 3

File details

Details for the file cblind-2.2.4.tar.gz.

File metadata

  • Download URL: cblind-2.2.4.tar.gz
  • Upload date:
  • Size: 222.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.5

File hashes

Hashes for cblind-2.2.4.tar.gz
Algorithm Hash digest
SHA256 693fa2db8d14ce432cdda43753bf201b71c6a829229ae5fce367fdf7b3ec4329
MD5 317293cfd95563ad1de3a960a38837f1
BLAKE2b-256 164f3263b643e12e731c0e2b2eafc6934927266f1d270f0fe4aee1e2a1d10a2f

See more details on using hashes here.

File details

Details for the file cblind-2.2.4-py3-none-any.whl.

File metadata

  • Download URL: cblind-2.2.4-py3-none-any.whl
  • Upload date:
  • Size: 20.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.1 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.8.5

File hashes

Hashes for cblind-2.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 fe5333a89b80a3d2670bcfe6b086b9aeacd816cea476d8a1a408f288b841247a
MD5 8ed90f80b88a5333e65af56b8f70a0cf
BLAKE2b-256 5ff96869c6459727675cbf24f31ef56b4278d779905cc36a4e423b703ad7ab96

See more details on using hashes here.

Supported by

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