Giter VIP home page Giter VIP logo

scicm's Introduction

SciCM: Scientific Colour Maps

Github release PyPI version License GitHub Actions CI

SciCM is a Python package aimed at providing a large set of colour maps designed for scientific data visualisation. The colour maps in SciCM have been designed to be as interchangeable as possible within the same category, e.g., all diverging colour maps included in SciCM do an (almost) equal job of displaying the data. All colour maps included in SciCM remain readable for people with red-green colour blindness (the most common type). This design frees the user in their choice of colour map to use for their data visualisation. SciCM also includes some simple colour map manipulation tools, for users that want to further customise their colour maps.

Quick start

Upon importing SciCM, the colour maps are registered with matplotlib, so they can be accessed by passing cmap='scicm.cmapname' to any plotting function that accepts a colour map (e.g. the cmap keyword in matplotlib). The colour map objects themselves can also be explicitly accessed using scicm.cm.cmapname. All colour maps have a reversed version, accessible through the same naming convention used by matplotlib (i.e. cmapname_r).

A simple example of SciCM in use:

    import numpy as np, matplotlib.pyplot as plt, scicm
    
    x = np.random.default_rng().normal(size=(200, 200))
    
    plt.imshow(x, cmap='scicm.Stone')
    plt.show()

Included Colour Maps

Documentation and use guides

SciCM's GitHub Wiki contains an extended quick start guide, the full documentation of the package, and a guide on how to choose the best colour map for your data.

SciCM in the broader colour map Python package ecosystem

SciCM is not the first package to include "good" (perceptually-uniform) colour maps, but meaningfully expands the current availabily of such maps. Compared to other similar packages:

  • matplotlib: Includes only 5 perceptually-uniform maps, which is less than 10% of all the available colour maps. The main aim of SciCM is to provide perceptually-uniform alternatives to the sequential, diverging, and cyclic colour map types in matplotlib.
  • ColorCET: Perhaps the closest colour map package to SciCM in both scope and size. The main difference being that ColorCET features a large set of variations for a small number of individual colour maps, whereas SciCM provides a large set of variations for a small number of colour map "types".
  • cmocean: A relatively small set of perceptually uniform colour maps, with a design clearly catered for geographic and oceanographic use. Of note is the oxy colour map included in cmocean, which was the main source of inspiration for SciCM's segmented category of colour maps.
  • CMasher: While there is some overlap between both packages, CMasher and SciCM are natural companions, as the two focus on offering alternatives to different sets of matplotlib's colour map categories.

Installation guide

The package is available for installation using pip:

>pip install scicm

Although you may wish to install it directly from GitHub, the following example being for the master branch:

>pip install git+https://github.com/MBravoS/scicm.git@master

How to cite the use of SciCM

If you are submitting work that uses SciCM for publication in a scientific journal, please include a mention of your use. Some journals include a dedicated section for this purpose (e.g., the Software section in the Astrophysical Journal), which would be the natural place to mention SciCM (please include a link to this repository). If such a section is not included on your journal or choice, please consider adding the following to your acknowledgements:

The analysis in this work has been performed using the Python programming language, with the open-source package SciCM (https://github.com/MBravoS/scicm).

Feel free to expand the previous statement to include the rest of the sofware used in your work! Note that we aim to submit SciCM for publication sometime in 2023, so how to acknowledge your use of SciCM will (hopefully) soon change.

scicm's People

Contributors

astrorobin avatar mbravos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

scicm's Issues

Simplifying the README and moving most of its current content to the GitHub wiki

I've been thinking that we could use the wiki to expand on the logic and examples. After reading the GitHub pages on README and wikis, I think a good start would be to start by cleaning up the former and moving those contents to the former. Further expanding the wiki as we see fit could also a good first step towards the short paper we have discussed with @AstroRobin once we get SciCM to v1.0.0 (seems like the Journal of Open Research Software would be right journal?).

Issue with registering colourmaps on Windows

Speaking with a student using Python on Windows wanting to use Scicm on their machine. They were able to install and import scicm with no errors, but it appears as though the colourmaps are not being registered correctly, they all look like:
scicm.C:\\Users\\user\\path\\to\\python\\cmapname. Attached below is a screenshot of the error:
image

Looking at our code for registering colourmaps below:

# List of all colour maps in scicm
cmaps=[c.split('/')[-1].split('.')[0] for c in sorted(glob(f'{data_path}/*.txt'))]

it's because you are splitting filenames by '/', whereas Windows machines use \ or rather as a string literal: '\' to separate directories in paths. I think there should be a base function in Python that handles path names independently of the OS you are using.

Addition of "pastel" set of colour maps

From the discussion in #1 has become clear that we need to replace cmocean's lighten tool with a new set of colour maps. These maps should have a smaller lightness dynamic range and chroma values to reproduce the effect of lighten when used on top of a white background (the most likely scenario).

Colour map manipulation tools

With @AstroRobin we have discussed before including some of the functions included in cmocean, and while crop and crop_by_percent are straightforward to add (and I'm hoping to add soon), lighten is not. They change the alpha to increase the lightness of the colour maps, which has three issues:

  • It only works for light backgrounds, as matplotlib performs alpha compositing with it. Using a dark background will actually make the colour map appear darker.
  • It will blend with anything else that has alpha<1.
  • The alpha compositing is made in CIE XYZ (a RGB colour space), which means that linear colour maps become strongly non-linear.
    I need to think more about this, but possibly doing the compositing in any La*b* colour space (like CAM02-UCS) could fix this.

Set monochromatic colour maps to the same lightness range

Toying around with the new manipulation tools (#1 ) it became obvious that we should set as many of our colour maps to the same lightness range. Since we now have the tools to encourage the user to create new colour maps, they should mix together nicely, without jumps in lightness. I settled on a 0.1<L*<0.9 range as that is the most common among our colour maps, and made new versions for maps not using that range (Blue, Cyan, Green, Magenta, Orange, Stone and Yellow), with the .jscm files and visualisations in my development branch.

Discussing this with @AstroRobin there is no obvious reason to generate near-duplicate maps, so these would be replacing the current ones. I'm not including Garnet, Tropical and Ripe in this remake, as those have shortened dynamic ranges by design.

More diverging colour maps

Our initial selection of diverging colour maps was rather opinionated, with only some colour pairs used (based mostly on personal preference) and biased towards maps that diverge from black (uniform maps that diverge from white are more common). We should expand our selection to any colour pair that is friendly at least at least for green-red colour blindness, as there is no good reason not to.

Separating "miscellaneous" category into an expanded "segmented" and "true" "miscellaneous"

This issue is really just for housekeeping purposes, as with @AstroRobin we have already agreed to expand Edges into a family of colour-grey-colour maps. This set of "segmented" colour maps will be made up of a group of Edges-like maps plus Quartile. The Edges "family" will be each based on one colour, e.g., EdgesBlue will be like current Edges but with both ends in blue. As part of this update the current Edges will be removed, as it will be easily recreated using our merge tool. This will take priority over adding isoluminant maps (#5), but will come after the expanded set of diverging maps (#2).

Publishing SciCM in conda-forge

We already have the package in PyPI, but it would seem like a good idea to also add it to conda-forge. I found this page which explains why and (roughly) how to do it, and to me it seems like a good idea. Though I'm not sure if why should hold until we are closer to v1.0.0. What do you think @AstroRobin?

Submission to pyOpenSci

I've been looking into the idea we had with @AstroRobin some time ago of submitting this package for publication. If I remember correctly, our original idea was to submit it to the Journal of Open Source Software, but looking into their stated scope I think SciCM wouldn't pass their selection criteria. They suggest an alternative in their detailed documentation, pyOpenSci, and looking into their scope I think this is the better option for SciCM. They do have some requirements that the package needs to meet, so for the moment I'm working from their (currently incomplete) package guide. I think this should be the next goal for SciCM, and once submitted (or ideally approved) we can move on with #8 and #9.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.