Created
June 19, 2019 19:51
-
-
Save msbc/2f750007acfad00786aaeccfaa5d7a3b to your computer and use it in GitHub Desktop.
Colormaps
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from matplotlib.colors import LinearSegmentedColormap as LSC | |
from matplotlib.cm import register_cmap | |
def modulo_cmap(cmap, name=None): | |
colors = np.roll(cmap(np.arange(cmap.N)), cmap.N // 2, axis=0) | |
if name is None: | |
name = map.name + "_mod" | |
return LSC.from_list(name, colors, cmap.N) | |
# erdc_iceFire colormap from Paraview | |
_colors = [[0.000000, 0.000000, 0.000006], | |
[0.000000, 0.120401, 0.302675], | |
[0.000000, 0.216583, 0.524574], | |
[0.055247, 0.345025, 0.659500], | |
[0.128047, 0.492588, 0.720288], | |
[0.188955, 0.641309, 0.792092], | |
[0.327673, 0.784935, 0.873434], | |
[0.608240, 0.892164, 0.935547], | |
[0.881371, 0.912178, 0.818099], | |
[0.951407, 0.835621, 0.449279], | |
[0.904481, 0.690489, 0.000000], | |
[0.854070, 0.510864, 0.000000], | |
[0.777093, 0.330180, 0.000882], | |
[0.672862, 0.139087, 0.002694], | |
[0.508815, 0.000000, 0.000000], | |
[0.299417, 0.000366, 0.000548], | |
[0.015752, 0.003320, 0.000000]] | |
erdc_iceFire = LSC.from_list("erdc_iceFire", _colors, 256) | |
erdc_iceFire_rev = LSC.from_list("erdc_iceFire_rev", _colors[::-1], 256) | |
# my (msbc) modification to the colormap | |
_my_c = _colors[:] | |
_my_c[8] = [1, 1, 1] | |
msbc_iceFire = LSC.from_list("msbc_iceFire", _my_c[::-1], 256) | |
msbc_iceFire_rev = LSC.from_list("msbc_iceFire_rev", _my_c, 256) | |
sn_iceFire = modulo_cmap(msbc_iceFire, "sn_iceFire") | |
sn_iceFire_rev = modulo_cmap(msbc_iceFire_rev, "sn_iceFire_rev") | |
for i in [sn_iceFire]: | |
register_cmap(cmap=i) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment