How to customize a color bar in matlab plot?
65 ビュー (過去 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!