Coder Social home page Coder Social logo

benmaier / cividis Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 73 KB

Register `cividis` with matplotlib, a color map optimized for color vision deficiency, as published in Nuñez, et al. (2018), PLoS ONE 13(7): e0199239 .

License: Other

Makefile 0.67% Python 99.33%
cividis matplotlib colormap cvd

cividis's Introduction

cividis

Register the color map cividis for matplotlib, as described in

Nuñez JR, Anderton CR, Renslow RS (2018) Optimizing colormaps with consideration for color vision deficiency to enable accurate interpretation of scientific data. PLoS ONE 13(7): e0199239.

Install

pip install cividis

Usage

After installation, just import cividis once and it's registered and usable

import cividis

Afterwards, you can use it like any other color map.

import matplotlib.pyplot as pl
import numpy as np

x = np.arange(0, 2*np.pi, 0.07)
y = np.arange(0, 2*np.pi, 0.07)
X, Y = np.meshgrid(x,y)
Z = np.cos(X) * np.sin(Y) * 20
Z += np.random.randn(*Z.shape)

pl.figure(figsize=(4,3.375))
pl.imshow(Z,cmap='cividis')
pl.colorbar()
pl.gcf().savefig('xmpl.png',dpi=150)

pl.show()

More examples

Register cividis as default

This has to be done once in your matplotlibrc file, or you call the corresponding function from the package.

import cividis
cividis.make_default()

 ...

pl.imshow(Z)

Will give equal results to the above.

Get an array of N cividis colors

import cividis
color_list = cividis.get_colors(10,n_start=2,n_end=200)

Where the function is implemented as

def get_colors(N, n_start=0, n_end=255):
    """Get a color array of `N` entries, where the `N` entries
    are taken at equidistance from the `cividis` array between
    `n_start` and `n_end`"""

    indices = np.linspace(n_start, n_end, N)
    indices = np.array(indices, dtype=int)
    return cividis[indices]

cividis's People

Contributors

benmaier avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

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.