Skip to main content

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

Project description

colorblind

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

I. INSTALLATION
pip install cblind

II. USAGE FOR PLOTTING
import cblind as cb
5 palette functions for now
6 test plotting functions

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)

color, linestyle = cb.Coloplots().contrast(nb_of_plots)
for less than 4 contrast plots [DISTINCT COLORS]
For more than 4 plots, the linestyle is changed
cb.test_contrast(nb_of_plots)

color, linestyle = cb.Coloplots().huescale(nb_of_plots, \*option)
from 1 to 9 plots [SEQUENTIAL DATA]
cb.test_huescale(nb_of_plots, \*option)
With option 'blue','bluegreen','green',
'gold','brown','rose','purple' for less than 3 plots, otherwise ocherscale

color, linestyle = cb.Coloplots().rbscale(nb_of_plots)
from 3 to 11 plots [DIVERGING DATA]
cb.test_rbscale(nb_of_plots)

color, linestyle = cb.Coloplots().solstice(nb_of_plots)
for less than 11 plots [DIVERGING DATA]
cb.test_solstice(nb_of_plots)

color, linestyle = cb.Coloplots().bird(nb_of_plots)
for less than 9 plots [DIVERGING DATA]
cb.test_bird(nb_of_plots)

color, linestyle = cb.Coloplots().pregunta(nb_of_plots)
for less than 9 plots [DIVERGING DATA]
cb.test_pregunta(nb_of_plots)

color, linestyle = cb.Coloplots().rainbow(nb_of_plots)
from 4 to 12 plots [RAINBOW SCHEME]
cb.test_rainbow(nb_of_plots)

color, linestyle = cb.Coloplots().monocolor(nb_of_plots, \*option)
from 1 to 13 plots [MONOCOLOR/PRINTING]
monochromatic but different linestyles cb.test_monocolor(nb_of_plots, \*option) With option "b&w", "blue", "red", "yellow", "green", "purple"

III. USAGE OF COLORMAPS
cmap = cb.cbmap(palette, nbin)
palette : 'cb.rbscale', 'cb.rainbow', 'cb.huescale', 'cb.solstice', 'cb.bird', 'cb.pregunta', 'cb.iris', cf II., but also all colormaps from matplotlib + "_r" variants for reverse colormaps
nbin : discretization of the colormap
data2d : 2D field

a) Example, with a field data2d
import matplotlib.pyplot as plt

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

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

b) Basic mapping functions

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

cb.test_mapping(palette,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.2.tar.gz (20.0 kB view details)

Uploaded Source

Built Distribution

cblind-2.2.2-py3-none-any.whl (19.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cblind-2.2.2.tar.gz
  • Upload date:
  • Size: 20.0 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.2 CPython/3.8.5

File hashes

Hashes for cblind-2.2.2.tar.gz
Algorithm Hash digest
SHA256 cdfe7df29ed15998621692194f0d39cd7726b633cc7f9ed3ceac566795b90ba0
MD5 64dcf1653ad02ae77e8fba2f5d97bfbf
BLAKE2b-256 dc89479ea8f1c1052c374676a161cd0f32cda864d01a21c4b0f761d2387319af

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cblind-2.2.2-py3-none-any.whl
  • Upload date:
  • Size: 19.4 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.2 CPython/3.8.5

File hashes

Hashes for cblind-2.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 266792aeb58fc2b8ccc0349e61145cf12af6d63a95342e5a519c2452fea5e301
MD5 ed9d45d9e8f648516917e5e2fcfd4333
BLAKE2b-256 0b3260129e73a302584a1278af7496fe7db13fde3fe2730a5741634174804fbf

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