Created
May 12, 2022 19:23
-
-
Save lukeolson/e508fcb723162f7c99b14d3ebc3813ce to your computer and use it in GitHub Desktop.
Wes Anderson color pallete, matplotlib
This file contains 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
# colors from here (MIT): | |
# https://github.com/karthik/wesanderson/blob/master/R/colors.R | |
# example from here: | |
# https://matplotlib.org/3.5.0/gallery/color/custom_cmap.html | |
import numpy as np | |
import matplotlib as mpl | |
import matplotlib.pyplot as plt | |
from matplotlib.colors import LinearSegmentedColormap | |
x = np.arange(0, np.pi, 0.1) | |
y = np.arange(0, 2 * np.pi, 0.1) | |
X, Y = np.meshgrid(x, y) | |
Z = np.cos(X) * np.sin(Y) * 10 | |
wacolors = {\ | |
'bottlerocket1' : ("#A42820", "#5F5647", "#9B110E", "#3F5151", "#4E2A1E", "#550307", "#0C1707"), | |
'bottlerocket2' : ("#FAD510", "#CB2314", "#273046", "#354823", "#1E1E1E"), | |
'rushmore1' : ("#E1BD6D", "#EABE94", "#0B775E", "#35274A" ,"#F2300F"), | |
'rushmore' : ("#E1BD6D", "#EABE94", "#0B775E", "#35274A" ,"#F2300F"), | |
'royal1' : ("#899DA4", "#C93312", "#FAEFD1", "#DC863B"), | |
'royal2' : ("#9A8822", "#F5CDB4", "#F8AFA8", "#FDDDA0", "#74A089"), | |
'zissou1' : ("#3B9AB2", "#78B7C5", "#EBCC2A", "#E1AF00", "#F21A00"), | |
'darjeeling1' : ("#FF0000", "#00A08A", "#F2AD00", "#F98400", "#5BBCD6"), | |
'darjeeling2' : ("#ECCBAE", "#046C9A", "#D69C4E", "#ABDDDE", "#000000"), | |
'chevalier1' : ("#446455", "#FDD262", "#D3DDDC", "#C7B19C"), | |
'fantasticfox1' : ("#DD8D29", "#E2D200", "#46ACC8", "#E58601", "#B40F20"), | |
'moonrise1' : ("#F3DF6C", "#CEAB07", "#D5D5D3", "#24281A"), | |
'moonrise2' : ("#798E87", "#C27D38", "#CCC591", "#29211F"), | |
'moonrise3' : ("#85D4E3", "#F4B5BD", "#9C964A", "#CDC08C", "#FAD77B"), | |
'cavalcanti1' : ("#D8B70A", "#02401B", "#A2A475", "#81A88D", "#972D15"), | |
'grandbudapest1' : ("#F1BB7B", "#FD6467", "#5B1A18", "#D67236"), | |
'grandbudapest2' : ("#E6A0C4", "#C6CDF7", "#D8A499", "#7294D4"), | |
'isleofdogs1' : ("#9986A5", "#79402E", "#CCBA72", "#0F0D0E", "#D9D0D3", "#8D8680"), | |
'isleofdogs2' : ("#EAD3BF", "#AA9486", "#B6854D", "#39312F", "#1C1718"), | |
'frenchdispatch' : ("#90D4CC", "#BD3027", "#B0AFA2", "#7FC0C6", "#9D9C85") | |
} | |
for key in wacolors.keys(): | |
cmap_name = key | |
colors = wacolors[cmap_name] | |
n_bins = [len(colors), 100] # Discretizes the interpolation into bins | |
fig, axs = plt.subplots(1, 2, figsize=(6, 9)) | |
for n_bin, ax in zip(n_bins, axs.flat): | |
cmap = LinearSegmentedColormap.from_list(cmap_name, colors, N=n_bin) | |
im = ax.imshow(Z, origin='lower', cmap=cmap) | |
ax.axis('off') | |
ax.set_title("N bins: %s" % n_bin) | |
fig.colorbar(im, ax=ax, shrink=0.5) | |
t = ax.text(0.5, 0.5, key, ha='center', transform=ax.transAxes, ) | |
t.set_bbox(dict(facecolor='white')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment