Reading-eScience-Centre / edal-java

Environmental Data Abstraction Layer libraries
Other
39 stars 30 forks source link

add Perceptually Uniform Sequential colormaps from matplotlib #41

Closed PBrockmann closed 8 years ago

PBrockmann commented 8 years ago

Add just 4 palette files with 50 colors coming from matplotlib 1.5.0 ('viridis', 'inferno', 'plasma', 'magma')

Create with

#!/usr/bin/env python

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

# Have colormaps separated into categories:
# http://matplotlib.org/examples/color/colormaps_reference.html

cmaps = [('psu',  # Perceptually Uniform Sequential'
                ['viridis', 'inferno', 'plasma', 'magma'])
        ]

levels = 50

for cmap_category, cmap_list in cmaps:
    for cmap_name in cmap_list:
        print cmap_category+'_'+cmap_name

        file = open(cmap_category + "-" + cmap_name + ".pal", "w")

        cmap = plt.get_cmap(cmap_name)
        colors = cmap(np.linspace(0, 1, levels))

        for i,c in enumerate(colors):
                c = matplotlib.colors.rgb2hex(c)
                file.write("%s\n" %(c))

        file.close()
guygriffiths commented 8 years ago

Great, thanks. They look good and they'll be in the next release. :)