Last active
December 17, 2015 13:29
-
-
Save cversek/5617579 to your computer and use it in GitHub Desktop.
Jeff's HSV Colormap in 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
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