Created
May 15, 2010 23:24
-
-
Save jgomezdans/402500 to your computer and use it in GitHub Desktop.
Random colormap for matplotli
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 matplotlib,numpy | |
import pylab | |
# A random colormap for matplotlib | |
cmap = matplotlib.colors.ListedColormap ( numpy.random.rand ( 256,3)) | |
pylab.imshow ( Z, cmap = cmap) | |
pylab.show() |
Try the following if you want a randomly shuffled version of an existing colormap (might be useful to avoid potentially bad colors from using purely random RGB values):
import numpy as np
import matplotlib.pyplot as plt
vals = np.linspace(0,1,256)
np.random.shuffle(vals)
cmap = plt.cm.colors.ListedColormap(plt.cm.jet(vals))
replacing jet
with the colormap of your choice.
hello. If you have a way to perform the same operation in opencv, i'm really interested ! (cmap isn't a proper opencv colormap)
Brilliant, even better than glasbey on ImageJ
This is awesome, very helpful. Thank you!
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
slick!