Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Colormaps "jet" and "hsv" #75

Open
rleegates opened this issue Dec 24, 2014 · 3 comments
Open

Colormaps "jet" and "hsv" #75

rleegates opened this issue Dec 24, 2014 · 3 comments

Comments

@rleegates
Copy link

Dear Color developers:

Borrowing from MATLAB's colormaps, is it possible to create the colormaps "jet" and "hsv". If so, how could this be done?

Best,
Robert

@m-lohmann
Copy link
Contributor

I found the following for the jet color LUT:

http://cresspahl.blogspot.de/2012/03/expanded-control-of-octaves-colormap.html

the r,g,b components of the jet LUT (256 color values) are defined by a simple scheme:

r,g,b=zeros(256),zeros(256),zeros(256)
for i = 0:255
  n=4*i/256
  r[i+1]=255*min(max(min(n-1.5,-n+4.5),0),1);
  g[i+1]=255*min(max(min(n-0.5,-n+3.5),0),1);
  b[i+1]=255*min(max(min(n+0.5,-n+2.5),0),1);
end

I found a list of MATLAB color LUTs here:

http://matlab.izmiran.ru/help/techdoc/ref/colormap.html

hsv seems to be just a variation of the typical rainbow scheme. You can easily build your own if you just work in the HSV color space, define a saturation and value (lightness) and let the hue go from 0 to 360 degrees. If you want to start the rainbow at a different color, just let the hue go from any angle to this angle+360 degrees.

@rleegates
Copy link
Author

Thank you very much, I'll have a look at it when I'm back to plotting :)

@lobingera
Copy link

Actually both can be done as one-liners:

cm = linspace(Color.HSV(0,1,1),Color.HSV(330,1,1),64)

for HSV, just a linspace in H (0...330).
a4

cm = RGB{Float64}[
    RGB(
        clamp(min(4x - 1.5, -4x + 4.5) ,0.0,1.0),
        clamp(min(4x - 0.5, -4x + 3.5) ,0.0,1.0),
        clamp(min(4x + 0.5, -4x + 2.5) ,0.0,1.0))  
    for x in linspace(0.0,1.0,64)]

for jet. I copied this from the Winston source (there is a reference).
a5

Maybe a documentation issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants