How to customize a color bar in matlab plot?
59 次查看(过去 30 天)
显示 更早的评论
I want to create a color bar similar to this one (see the attachment). The zero value is white and has different jet patterns on both side (positive and negative). Thanks
0 个评论
回答(3 个)
DGM
2023-1-15
For what it's worth, here's the same colormap reconstructed. The map is PWL in RGB, so it's easy enough.
% generate a new CT from a list of breakpoints
N = 256; % new CT length
x = [0 48 84 128 168 199 256]/256;
CT0 = [1 0 1; 0 0 0.85; 0 1 1; 1 1 1; 0 1 0; 1 1 0; 1 0 0];
xf = linspace(0,1,N);
CT = interp1(x,CT0,xf,'linear','extrap');
% plot the channel trajectories (it's PWL)
plot(CT(:,1),'r'); hold on
plot(CT(:,2),'g')
plot(CT(:,3),'b')
% use the map to plot something
x = linspace(-pi/2,pi/2,30);
y = x.';
z = sin(x).*sin(y);
surf(x,y,z)
colormap(CT)
colorbar
view(-17,50)
Though there are many other bidirectional colormaps out there that would be better.
0 个评论
KSSV
2017-12-7
c1 = jet ;
c2 = [1 1 1] ;
c3 = hsv ;
c = [c1 ; c2; c3] ;
[X,Y,Z] = peaks(100) ;
surf(X,Y,Z)
colorbar
colormap(c)
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Colormaps 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!