Skip to main content

Collections of color maps for scientific visualizations

Project description

Introduction

PyPI version

This python package contains a collection of nice color maps for scientific visualizations and provides a convinient and unified way to pick the color maps. Some color maps are perceptually uniform and/or color blind friendly.

You can also check out the Scicolor Color Picker, a web app for browsing and picking colors.

Quick start

Install

The package is available through pypi. You can install it using the following command:

pip install scicolor

Import the package

import scicolor

Get a color map

scicolor.get_cmap('viridis')

scicolor.get_cmap() works just like plt.get_cmap(). The returned value can be instances of either matplotlib.colors.ListedColormap or matplotlib.colors.LinearSegmentedColormap.

You can access the colors of matplotlib.colors.ListedColormap instances by .colors.

List available color maps

List all color maps

scicolor.list_cmaps()

List the color maps that are sequential, discrete, and color blind friendly

scicolor.list_cmaps(cm_class='sequential', cm_type="discrete", color_blind_friendly=True)

See below for more on the classes and types of the color maps.

Plot color maps

Plot a color map

scicolor.plot_cmaps('tab20')

Plot multiple color maps

scicolor.plot_cmaps(['tab20', 'tab20b'])

Plot the color maps that are sequential, discrete, and color blind friendly

scicolor.plot_cmaps(cm_class='sequential', cm_type="discrete", color_blind_friendly=True)

Below is a screen shot of scicolor.plot_cmaps(), which shows all available color maps.

list

Characteristics of the color maps

See the following table for different characteristics of the color maps. You can use the corresponding paramters in scicolor.list_cmaps() and scicolor.plot_cmaps() to filter the results.

Characteristic Parameter Values
class cm_class 'categorical', 'diverging', 'misc', 'multi_sequential', 'sequential'
type cm_type 'categorical', 'continuous', 'discrete'
perceptually uniform perceptually_uniform True, None
color blind friendly color_blind_friendly True, None

See the guideline below for more on the class and type.

Guideline for choosing color maps

Figure below contains the guideline for choosing color maps.

guideline

The figure was borrowed from The misuse of colour in science communication.

Color maps sources

The color maps come from different sources, see the table below for details

Source Color maps Link
matplotlib tab20, tab20b, tab20c, viridis, inferno, cividis https://matplotlib.org/3.1.0/tutorials/colors/colormaps.html
Scientific colour maps batlow10, batlow25, acton10, acton25, oslo10, oslo25, turku10, turku25, vik10, vik25, roma10, roma25, broc10, broc25, oleron10, oleron25, batlowS, batlow, acton, oslo, turku, vik, roma, broc, oleron http://www.fabiocrameri.ch/colourmaps.php
Wes Anderson Royal2, Zissou1, Darjeeling1, FantasticFox1, Moonrise3, Cavalcanti1, GrandBudapest2, IsleofDogs2 https://github.com/karthik/wesanderson
CET glasbey, cwr, isolum https://peterkovesi.com/projects/colourmaps/
ocean topo https://matplotlib.org/cmocean/
Met Brewer Archambault, Cassatt1, Cassatt2, Demuth, Derain, Egypt, Greek, Hiroshige, Hokusai2, Ingres, Isfahan1, Isfahan2, Java, Johnson, Kandinsky, Morgenstern, OKeeffe1, OKeeffe2, Pillement, Tam, Troy, Veronese https://github.com/BlakeRMills/MetBrewer

Matplotlib

The present package simply offers a wrapper for the selected color maps that are included in matplotlib. To add more matplotlib color maps to scicolor, just add the information to color_info_list in __init__.py.

Scientific colors

Scientific colour maps provides a series of perceptually uniform and color blind friendly color maps. To expand the list included in scicolor:

  1. Download the data from zenodo
  2. Copy the .txt files to /path/to/scicolor/scicolor/scientific_colors
  3. Add the information to color_info_list in __init__.py

Wes Anderson

Wes Anderson Palettes provides a series of categorical colors extract from Wes Anderson movies. Note that the color maps might not be color blind friendly, use with cautions. To expand the list:

  1. Copy the color data to __init__.py
  2. Add the information to color_info_list in __init__.py

CET

CET (Centre for Exploration Targeting) offers many perceptually uniform color maps. To expand the list

  1. Download the color data from github to /path/to/scicolor/scicolor/cet_colors
  2. Assgin meaniful names to the color data files. References can be found in their script
  3. Add the information to color_info_list in __init__.py

ocean

CMOcean (colormaps inspired by oceanography) provides a series of perceptually uniform color maps. To expand the list

  1. Download the color data from github to /path/to/scicolor/scicolor/ocean_colors
  2. Add the information to color_info_list in __init__.py

MetBrewer

MetBrewer provides a series of palettes inspired by works at the Metropolitan Museum of Art in New York. Currently the scicolor package only includes the color-blind-friendly colors from MetBrewer.

Requirements

  • python3
  • matplotlib
  • pandas
  • numpy

Development and Publishing

For Contributors

This project uses uv for dependency management and packaging.

Setup Development Environment

# Install dependencies and sync virtual environment
uv sync

# Test the package
uv run python -c "import scicolor; print(scicolor.list_cmaps())"

Adding Dependencies

# Add a new dependency
uv add package-name

# Add a development dependency
uv add --dev package-name

Developing locally

Test the package locally with Jupyter notebooks through the following command:

uv run --with jupyter jupyter notebook

Bump the version of the package with the following command:

uv version --bump <patch|minor|major>

Publishing to PyPI

Testing with TestPyPI (Recommended First)

Before publishing to the real PyPI, test with TestPyPI:

  1. Create TestPyPI Account

  2. Create API Token

  3. Build and Publish to TestPyPI

    # Clean previous builds
    rm -rf dist/
    
    # Build the package
    uv build
    
    # Publish to TestPyPI
    uv publish --publish-url https://test.pypi.org/legacy/
    
    # When prompted:
    # Username: __token__
    # Password: <paste your TestPyPI token>
    
  4. Test Installation from TestPyPI

    pip install --index-url https://test.pypi.org/simple/ --extra-index-url https://pypi.org/simple/ scicolor
    

    Note: --extra-index-url is needed because dependencies are on regular PyPI.

Publishing to Production PyPI

Once verified on TestPyPI:

  1. Create PyPI Account

  2. Create API Token

  3. Build and Publish

    # Clean and build
    rm -rf dist/
    uv build
    
    # Publish to PyPI
    uv publish
    

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

scicolor-1.3.tar.gz (93.6 kB view details)

Uploaded Source

Built Distribution

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

scicolor-1.3-py3-none-any.whl (100.6 kB view details)

Uploaded Python 3

File details

Details for the file scicolor-1.3.tar.gz.

File metadata

  • Download URL: scicolor-1.3.tar.gz
  • Upload date:
  • Size: 93.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for scicolor-1.3.tar.gz
Algorithm Hash digest
SHA256 b9cd31ed4e7a35ca5ff774c70960b5dff0ed490b0677ce45ce9f892f43ab51b6
MD5 8349a4621a9b04e213e17e483a051430
BLAKE2b-256 bf3432c36257e4a18dd9a7a8efdf6acce059a0d819f475b6ef7d817327fe3186

See more details on using hashes here.

File details

Details for the file scicolor-1.3-py3-none-any.whl.

File metadata

  • Download URL: scicolor-1.3-py3-none-any.whl
  • Upload date:
  • Size: 100.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for scicolor-1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e285d955b09e6f6f0cda2c74f20d2bb01369f4421c287fad582e3f30a5c4343f
MD5 457fb8d22fd7fcc080a6222c28920d6b
BLAKE2b-256 00207c6c7abfd18944f62f78783b2461c870a7c5f86e4ec1f504cb7462745a8a

See more details on using hashes here.

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