Giter Site home page Giter Site logo

gavin971 / cmaps Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hhuangwx/cmaps

1.0 2.0 0.0 5.99 MB

user defined colormaps in matplotlib.

Home Page: https://github.com/hhuangwx/cmaps

License: GNU General Public License v3.0

Python 18.77% NCL 2.38% Jupyter Notebook 78.85%

cmaps's Introduction

cmaps

Make it easier to use user defined colormaps in matplotlib. Default colormaps are from NCL website.

examples/colormaps.png

Users can define a environmental variable CMAP_DIR pointing to the folder containing the self-defined rgb files.

Installation:

git clone https://github.com/hhuangwx/cmaps.git
cd cmaps
python setup.py install

Usage:

import matplotlib.pyplot as plt
import cmaps
import numpy as np

x = y = np.arange(-3.0, 3.01, 0.05)
X, Y = np.meshgrid(x, y)
Z1 = plt.mlab.bivariate_normal(X, Y, 1.0, 1.0, 0.0, 0.0)
plt.pcolormesh(X,Y,Z1,cmap=cmaps.WhiteBlueGreenYellowRed)
plt.colorbar()
plt.show()

List the colormaps using the code in the examples:

import cmaps
import numpy as np
import matplotlib.pyplot as plt
import matplotlib
matplotlib.rc('text', usetex=False)
a = np.outer(np.arange(0, 1, 0.001), np.ones(10))
plt.figure(figsize=(20, 10))
plt.subplots_adjust(top=0.95, bottom=0.05, left=0.01, right=0.99)
cmap_d = cmaps.cmap_dict()
ncmaps = len(cmap_d.keys())
nrows = 4
for i, k in enumerate(cmap_d.keys()):
    plt.subplot(nrows, ncmaps // nrows + 1, i + 1)
    plt.axis('off')
    plt.imshow(a, aspect='auto', cmap=cmap_d[k], origin='lower')
    plt.title(k, rotation=90, fontsize=10)
    plt.title(k, fontsize=10)
plt.savefig('colormaps.png', dpi=300)

cmaps's People

Contributors

hhuangwx avatar

Stargazers

 avatar

Watchers

James Cloos avatar FU Zhipeng 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.