Cyclic colormap for visualizing angles

120 visualizaciones (últimos 30 días)
Aamir
Aamir el 9 de Nov. de 2011
Editada: DGM el 26 de Nov. de 2023
I am visualizing angles of a norm-preserving vector field, please see http://www.flickr.com/photos/aamirahmed/6328889041/in/photostream The colors in this photo represent the direction of the vector (relative to +x axis) at that point.
With the built-in colormaps, there is an abrupt change in the colors between -180 and 180. This is very misleading, since angles are cyclic numbers, for example 90 and 100 are as close to each other as 175 and -175.
I think this problem can be addressed by using a cyclic colormap. By cyclic colormap, I mean when approaching the maximum value in the colormap, it blends into the minimum value, with no abrupt change in between.
Does anybody else here feel for the need of a cyclic colormap for this purpose? Please share if you already have a cyclic colormap. Also please suggest other solutions to address this problem.

Respuesta aceptada

Chad Greene
Chad Greene el 9 de Mayo de 2016
I've written a phasemap function for this, built on Kristen Thyng's cmocean phase colormap. It has an approximately constant lightness profile, which places even emphasis on all phase values.

Más respuestas (3)

Dr. Seis
Dr. Seis el 9 de Nov. de 2011
You can pick out your favorite colormap (doc colormap for examples) and then just wrap it around itself. So, for example, you can create:
jet_wrap = vertcat(jet,flipud(jet));
Then you just add this line after you plot:
colormap(jet_wrap);
Does this do what you want?... because it will make it so that abs(angle) equals the same color.
  1 comentario
Chad Greene
Chad Greene el 9 de Mayo de 2016
Editada: Chad Greene el 12 de Mayo de 2016
There is an issue with flipping and concatenating--often when phase is plotted we want to know whether phase is increasing or decreasing. If the colors go in one direction, then go in reverse order, there is no to ability to distinguish between increasing phase or decreasing phase.

Iniciar sesión para comentar.


Walter Roberson
Walter Roberson el 9 de Nov. de 2011
How about using the colormap named "hsv" ?
  2 comentarios
Aamir
Aamir el 9 de Nov. de 2011
I thought about HSV but it contains too many different and distracting colors. See here http://www.twitpic.com/7chnll
Walter Roberson
Walter Roberson el 9 de Nov. de 2011
hmap(1:256,1) = linspace(0,1,256);
hmap(:,[2 3]) = 0.7; %brightness
huemap = hsv2rgb(hmap);
colormap(huemap)

Iniciar sesión para comentar.


DGM
DGM el 26 de Nov. de 2023
Editada: DGM el 26 de Nov. de 2023
Here's a comparison, for what it's worth. I'm using multiple FEX tools here, so obviously this won't run if you don't go get the corresponding tools from the File Exchange.
% some colormaps
CT1 = phasemap(256); % Chad's phasemap()
CT2 = ccmap('hsyp',256); % MIMT ccmap()
CT3 = hsv(256); % base MATLAB
% can we subdue the hsv() map?
hmap(1:256,1) = linspace(0,1,256);
hmap(:,2) = 0.6; % saturation
hmap(:,3) = 0.7; % value
CT4 = hsv2rgb(hmap);
% visualize them
stripe = ctflop(cat(3,CT1,CT2,CT3,CT4));
image(stripe)
The 'hsyp' map from ccmap() isn't quite as uniform as phasemap(), but that comes with the low cost of using HSYp. It's a bit lighter than phasemap(), which may be good or bad, depending on what you want. I originally made it for line/mesh plots against a black background.
Using hsv() is one option, though it's not uniform. Much like with any rainbow map, one could argue that the regularity and distinctness of the primary-secondary intervals is a feature, but that's open for dispute. If the peakiness is undesired, desaturating hsv() doesn't do much to subdue the prominence of the secondary peaks.
Chad's phasemap() has some extra features, including the ability to provide a circular phase "color ring" for your figure.
There are other cyclic maps to be found. I think crameri() deserves mention, though you should probably do you own search and see what works best for you.
% cyclic maps from Chad Greene's crameri()
CT1 = crameri('romao');
CT2 = crameri('bamo');
CT3 = crameri('broco');
CT4 = crameri('corko');
CT5 = crameri('viko');
% visualize them
stripe = ctflop(cat(3,CT1,CT2,CT3,CT4,CT5));
image(stripe)
These are the FEX submissions I used.

Categorías

Más información sobre Colormaps en Help Center y File Exchange.

Productos

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by