Created
August 5, 2021 08:44
-
-
Save prerakmody/aa3996f2d40d6c7cad5a4ea8fb5d9eb5 to your computer and use it in GitHub Desktop.
Matplotlib Colors
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
import numpy as np | |
import matplotlib | |
import matplotlib.pyplot as plt | |
cmap = matplotlib.cm.get_cmap('magma') | |
f,axarr = plt.subplots(1,3) | |
x = np.arange(0,1,0.01) | |
img = np.zeros((len(x),len(x),4)) | |
for x_id, x_ in enumerate(x):img[x_id,:,:] = np.repeat(np.expand_dims(np.array(cmap(x_)), axis=0), len(x), axis=0) | |
axarr[0].imshow(img, cmap='magma') | |
x = np.arange(-1,2,0.01) | |
img = np.zeros((len(x),len(x),4)) | |
for x_id, x_ in enumerate(x):img[x_id,:,:] = np.repeat(np.expand_dims(np.array(cmap(x_)), axis=0), len(x), axis=0) | |
axarr[1].imshow(img, cmap='magma') | |
x = np.arange(-1,255,0.1) | |
img = np.zeros((len(x),len(x),4)) | |
for x_id, x_ in enumerate(x):img[x_id,:,:] = np.repeat(np.expand_dims(np.array(cmap(x_)), axis=0), len(x), axis=0) | |
axarr[2].imshow(img, cmap='magma') | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment