Unevenly Map Data to an RGB Map?
이전 댓글 표시
So I have made an RGB style map that mimics Matlab's color map options (just a different flavor, for stylistic reasons), and I want it to scale to the bottom two thirds of my data. I want it to linearly scale to the bottom two thirds because the peaks are so high that a perfect linear match hides small-scale detail elsewhere in the figures. Any good tricks?
For context, I'm plotting with surfc and then:
load('rgbmap.mat'); %Homemade colormap stored here as variable "map"
colormap(map);
c = colorbar;
Thank you.
댓글 수: 1
Mohammad Sami
2020년 9월 19일
The easiest way would be to edit the colour map in the figure GUI.
채택된 답변
추가 답변 (2개)
Mohammad Sami
2020년 9월 19일
0 개 추천
You can use the colormapeditor GUI to interactively create the colour map.
https://www.mathworks.com/help/matlab/ref/colormapeditor.html
If you want to take your colormap and shift it toward one end or the other for some reason, you might be able to do something like this:
% say you have some colormap
cmap0 = parula(64);
% scale adjustment parameter (range is [-1 1])
% when stretchamt = 0, no change
% when stretchamt < 0, stretch bottom of table upward
% when stretchamt > 0, stretch top of table downward
stretchamt = 0.5;
% delinearize adjustment parameter to get gamma
% apply gamma adjustment to primary axis of the CT
% conditionally flip table so xnew is effectively point-symmetric about [0.5 0.5]
% this limits the slope of xnew and avoids overcompressing the table for g<1
n = size(cmap0,1);
x = linspace(0,1,n);
if stretchamt > 0
g = 1 - min(1-eps,stretchamt);
xnew = x.^(1/g);
cmapnew = flipud(interp1(x,flipud(cmap0),xnew,'pchip'));
else
g = 1/(1 + max(eps-1,stretchamt));
xnew = x.^g;
cmapnew = interp1(x,cmap0,xnew,'pchip');
end
% cmapnew is your new color table
cmapnew
For sake of visualization, this is what the results look like for stretchamt equal to -0.6, -0.3, 0, 0.3, and 0.6 respectively

For a prebuilt tool that does this, see ctshift() from MIMT (on the File Exchange)
카테고리
도움말 센터 및 File Exchange에서 Blue에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!