Colormap

Example usage

A simple example of applying a colormap on data:

from trollimage.colormap import rdbu
from trollimage.image import Image

img = Image(data, mode="L")

rdbu.set_range(-90 + 273.15, 30 + 273.15)
img.colorize(rdbu)

img.show()
_images/hayan_simple.png

A more complex example, with a colormap build from greyscale on one end, and spectral on the other, like this:

_images/my_cm.png
from trollimage.colormap import spectral, greys
from trollimage.image import Image

img = Image(data, mode="L")

greys.set_range(-40 + 273.15, 30 + 273.15)
spectral.set_range(-90 + 273.15, -40.00001 + 273.15)
my_cm = spectral + greys
img.colorize(my_cm)

img.show()
_images/hayan.png

Now applying a palette to the data, with sharp edges:

from trollimage.colormap import set3
from trollimage.image import Image

img = Image(data, mode="L")

set3.set_range(-90 + 273.15, 30 + 273.15)
img.palettize(set3)

img.show()
_images/phayan.png

API

See the Colormap API documentation.

Default Colormaps

Colors from www.ColorBrewer.org by Cynthia A. Brewer, Geography, Pennsylvania State University.

Sequential Colormaps

blues

blues

bugn

bugn

bupu

bupu

gnbu

gnbu

greens

greens

greys

greys

oranges

oranges

orrd

orrd

pubu

pubu

pubugn

pubugn

purd

purd

purples

purples

rdpu

rdpu

reds

reds

ylgn

ylgn

ylgnbu

ylgnbu

ylorbr

ylorbr

ylorrd

ylorrd

Diverging Colormaps

brbg

brbg

piyg

piyg

prgn

prgn

puor

puor

rdbu

rdbu

rdgy

rdgy

rdylbu

rdylbu

rdylgn

rdylgn

spectral

spectral

Qualitative Colormaps

accent

accent

dark2

dark2

paired

paired

pastel1

pastel1

pastel2

pastel2

set1

set1

set2

set2

set3

set3

Rainbow Colormap

Don’t use this one ! See here and there why

rainbow

rainbow