Skip to content

Instantly share code, notes, and snippets.

@spotter
Created May 2, 2011 09:00
Show Gist options
  • Select an option

  • Save spotter/951323 to your computer and use it in GitHub Desktop.

Select an option

Save spotter/951323 to your computer and use it in GitHub Desktop.
How to make and use a DAB colormap.
#! /bin/usr/env python
# -*- coding: utf-8 -*-
"""Building DAB colormap."""
__author__ = "Xavier Moles Lopez <x.moleslo@gmail.com>"
__date__ = "01/05/11"
from pylab import *
from matplotlib.colors import LinearSegmentedColormap
# Definition des segments pour la couleurs DAB:
# Plus intense => plus foncé.
dab_dict = {'blue': [(0.0, 1.0, 1.0),
(0.20, 0.7647, 0.7647),
(0.40, 0.4902, 0.4902),
(0.60, 0.1765, 0.1765),
(0.80, 0.0392, 0.0392),
(1.00, 0.0, 0.0),
],
'green':[(0.0, 1.0, 1.0),
(0.20, 0.9098, 0.9098),
(0.40, 0.7608, 0.7608),
(0.60, 0.5059, 0.5059),
(0.80, 0.3176, 0.3176),
(1.00, 0.0, 0.0),],
'red': [(0.0, 1.0, 1.0),
(0.20, 1.0, 1.0),
(0.40, 0.8745, 0.8745),
(0.60, 0.7490, 0.7490),
(0.80, 0.5490, 0.5490),
(1.00, 0.3294, 0.3294),]}
# Création de la colormap
dab = LinearSegmentedColormap('my_colormap',dab_dict,256)
A = rand(10,10)
# Utilisation de la colormap dab.
pcolor(A,cmap=dab)
colorbar()
# Comparaison avec colormap jet.
figure()
pcolor(A,cmap=cm.jet)
colorbar()
show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment