Skip to content

Instantly share code, notes, and snippets.

@granttremblay
Last active December 12, 2019 04:33
Show Gist options
  • Save granttremblay/637ce90e09a39da0a6dcd949a9f8ef5c to your computer and use it in GitHub Desktop.
Save granttremblay/637ce90e09a39da0a6dcd949a9f8ef5c to your computer and use it in GitHub Desktop.
Paranal Colormaps (**NOT PERCEPTUALLY UNIFORM!! ***)
import json
from matplotlib.colors import LinearSegmentedColormap
from matplotlib.cm import register_cmap
cdict_sunset = {'red': [[0.0, 0.10980392156862745, 0.10980392156862745], [0.09090909090909091, 0.14901960784313725, 0.14901960784313725], [0.18181818181818182, 0.17254901960784313, 0.17254901960784313], [0.2727272727272727, 0.22745098039215686, 0.22745098039215686], [0.36363636363636365, 0.2549019607843137, 0.2549019607843137], [0.45454545454545453, 0.2901960784313726, 0.2901960784313726], [0.5454545454545454, 0.38823529411764707, 0.38823529411764707], [0.6363636363636364, 0.5333333333333333, 0.5333333333333333], [0.7272727272727273, 0.7058823529411765, 0.7058823529411765], [0.8181818181818182, 0.8392156862745098, 0.8392156862745098], [0.9090909090909091, 0.9764705882352941, 0.9764705882352941], [1.0, 1.0, 1.0]], 'green': [[0.0, 0.09803921568627451, 0.09803921568627451], [0.09090909090909091, 0.1411764705882353, 0.1411764705882353], [0.18181818181818182, 0.16470588235294117, 0.16470588235294117], [0.2727272727272727, 0.21568627450980393, 0.21568627450980393], [0.36363636363636365, 0.23921568627450981, 0.23921568627450981], [0.45454545454545453, 0.27450980392156865, 0.27450980392156865], [0.5454545454545454, 0.3843137254901961, 0.3843137254901961], [0.6363636363636364, 0.5137254901960784, 0.5137254901960784], [0.7272727272727273, 0.6784313725490196, 0.6784313725490196], [0.8181818181818182, 0.8235294117647058, 0.8235294117647058], [0.9090909090909091, 0.9254901960784314, 0.9254901960784314], [1.0, 0.8627450980392157, 0.8627450980392157]], 'blue': [[0.0, 0.17254901960784313, 0.17254901960784313], [0.09090909090909091, 0.22745098039215686, 0.22745098039215686], [0.18181818181818182, 0.25882352941176473, 0.25882352941176473], [0.2727272727272727, 0.32941176470588235, 0.32941176470588235], [0.36363636363636365, 0.3686274509803922, 0.3686274509803922], [0.45454545454545453, 0.403921568627451, 0.403921568627451], [0.5454545454545454, 0.5098039215686274, 0.5098039215686274], [0.6363636363636364, 0.6313725490196078, 0.6313725490196078], [0.7272727272727273, 0.7411764705882353, 0.7411764705882353], [0.8181818181818182, 0.8196078431372549, 0.8196078431372549], [0.9090909090909091, 0.8627450980392157, 0.8627450980392157], [1.0, 0.3607843137254902, 0.3607843137254902]]}
cdict_twilight = {'red': [[0.0, 0.10980392156862745, 0.10980392156862745], [0.09090909090909091, 0.14901960784313725, 0.14901960784313725], [0.18181818181818182, 0.17254901960784313, 0.17254901960784313], [0.2727272727272727, 0.22745098039215686, 0.22745098039215686], [0.36363636363636365, 0.2549019607843137, 0.2549019607843137], [0.45454545454545453, 0.2901960784313726, 0.2901960784313726], [0.5454545454545454, 0.38823529411764707, 0.38823529411764707], [0.6363636363636364, 0.5333333333333333, 0.5333333333333333], [0.7272727272727273, 0.7058823529411765, 0.7058823529411765], [0.8181818181818182, 0.8392156862745098, 0.8392156862745098], [0.9090909090909091, 0.9764705882352941, 0.9764705882352941], [1.0, 1.0, 1.0]], 'green': [[0.0, 0.09803921568627451, 0.09803921568627451], [0.09090909090909091, 0.1411764705882353, 0.1411764705882353], [0.18181818181818182, 0.16470588235294117, 0.16470588235294117], [0.2727272727272727, 0.21568627450980393, 0.21568627450980393], [0.36363636363636365, 0.23921568627450981, 0.23921568627450981], [0.45454545454545453, 0.27450980392156865, 0.27450980392156865], [0.5454545454545454, 0.3843137254901961, 0.3843137254901961], [0.6363636363636364, 0.5137254901960784, 0.5137254901960784], [0.7272727272727273, 0.6784313725490196, 0.6784313725490196], [0.8181818181818182, 0.8235294117647058, 0.8235294117647058], [0.9090909090909091, 0.9254901960784314, 0.9254901960784314], [1.0, 0.8627450980392157, 0.8627450980392157]], 'blue': [[0.0, 0.17254901960784313, 0.17254901960784313], [0.09090909090909091, 0.22745098039215686, 0.22745098039215686], [0.18181818181818182, 0.25882352941176473, 0.25882352941176473], [0.2727272727272727, 0.32941176470588235, 0.32941176470588235], [0.36363636363636365, 0.3686274509803922, 0.3686274509803922], [0.45454545454545453, 0.403921568627451, 0.403921568627451], [0.5454545454545454, 0.5098039215686274, 0.5098039215686274], [0.6363636363636364, 0.6313725490196078, 0.6313725490196078], [0.7272727272727273, 0.7411764705882353, 0.7411764705882353], [0.8181818181818182, 0.8196078431372549, 0.8196078431372549], [0.9090909090909091, 0.8627450980392157, 0.8627450980392157], [1.0, 0.3607843137254902, 0.3607843137254902]]}
cmap_sunset = LinearSegmentedColormap('sunset', segmentdata=cdict_sunset, N=256)
cmap_twilight = LinearSegmentedColormap('twilight', segmentdata=cdict_twilight, N=256)
register_cmap(name='sunset', cmap=cmap_sunset)
register_cmap(name='twilight', cmap=cmap_twilight)
json_sunset = json.dumps(cdict_sunset)
json_twilight = json.dumps(cdict_twilight)
with open("sunset.json", "w") as f:
f.write(json_sunset)
with open("twilight.json", "w") as f:
f.write(json_twilight)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment