Skip to content

Instantly share code, notes, and snippets.

@cversek
Last active December 17, 2015 13:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cversek/5617579 to your computer and use it in GitHub Desktop.
Save cversek/5617579 to your computer and use it in GitHub Desktop.
Jeff's HSV Colormap in Matplotlib
from pylab import *
cdict = {
'red' : ((0.00, 0.00, 0.00),
(0.20, 0.00, 0.00),
(0.40, 0.00, 0.00),
(0.60, 0.00, 0.00),
(0.80, 1.00, 1.00),
(1.00, 1.00, 1.00)),
'green': ((0.00, 0.00, 0.00),
(0.20, 0.00, 0.00),
(0.40, 1.00, 1.00),
(0.60, 1.00, 1.00),
(0.80, 1.00, 1.00),
(1.00, 0.00, 0.00)),
'blue' : ((0.00, 0.00, 0.00),
(0.20, 1.00, 1.00),
(0.40, 1.00, 1.00),
(0.60, 0.00, 0.00),
(0.80, 0.00, 0.00),
(1.00, 0.00, 0.00)),
}
custom_cmap = matplotlib.colors.LinearSegmentedColormap('jeffs_HSV',cdict,256)
#a demo 2d gaussian
L = linspace(-5,5,100)
X,Y = meshgrid(L,L)
Z = 2.0*exp(-(X**2 + Y**2)/10.0) - 1.0
imshow(Z,aspect='auto',cmap = custom_cmap,origin="lower", vmin=-1.0, vmax=1.0)
colorbar()
savefig("jeffs_HSV_colormap.png")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment