Cyclic colormap for visualizing angles

조회 수: 69 (최근 30일)
Aamir
Aamir 2011년 11월 9일
편집: DGM 2023년 11월 26일
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.

채택된 답변

Chad Greene
Chad Greene 2016년 5월 9일
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.

추가 답변 (3개)

Dr. Seis
Dr. Seis 2011년 11월 9일
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
Chad Greene
Chad Greene 2016년 5월 9일
편집: Chad Greene 2016년 5월 12일
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.

댓글을 달려면 로그인하십시오.


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

댓글을 달려면 로그인하십시오.


DGM
DGM 2023년 11월 26일
편집: DGM 2023년 11월 26일
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.

카테고리

Help CenterFile Exchange에서 Color and Styling에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by