Matlab 匹配颜色映射和颜色条

Matlab 匹配颜色映射和颜色条,matlab,matlab-figure,Matlab,Matlab Figure,我正在运行以下代码 % x_start y_start x_end y_end concentration A = [0 0 1 1 10 0 1 3 3 0.6 3 1 6 2 1.2]; cmap = jet(256); con_min = 0; con_max = 10; ind_c = round((size(cmap,1)-1)

我正在运行以下代码

%    x_start y_start x_end y_end concentration
A = [0         0      1      1     10
     0         1      3      3     0.6
     3         1      6      2     1.2];

cmap = jet(256);
con_min = 0;
con_max = 10;
ind_c = round((size(cmap,1)-1)*A(:,5)/(con_max-con_min))+1
figure;
set(gca,'ColorOrder',cmap(ind_c,:),'NextPlot','replacechildren');
plot([A(:,1) A(:,3)]',[A(:,2) A(:,4)]');
colorbar

但是,我的颜色栏与我的颜色映射不匹配;它使用默认的颜色栏,我正在运行一个自定义的颜色映射。如何使我的颜色栏显示我的颜色映射的正确值?

您不能使用
colormap(cmap)
而不是
set(gca、'ColorOrder',cmap(ind_c,:),'NextPlot','replacechildren')?@Dan Yep,就是这样!