答案 0 :(得分:4)
这是另一种选择 - 只需在特定值处添加/更改刻度标签:
MarkTxt = '<-Mark';
imagesc(rand(10)-2) % something to plot
colormap('jet')
CB = colorbar;
% in case you DON'T want the value to appear:
value = -1.8;
t = find(CB.Ticks==value);
if ~isempty(t)
CB.TickLabels{t} = MarkTxt;
else
[CB.Ticks,ord] = sort([CB.Ticks value],'ascend');
t = CB.Ticks==value;
CB.TickLabels{t} = MarkTxt;
end
%% OR - in case you want the value to appear:
value = -1.24;
t = find(CB.Ticks==value);
if ~isempty(t)
CB.TickLabels{t} = [CB.TickLabels{t} MarkTxt];
else
[CB.Ticks,ord] = sort([CB.Ticks value],'ascend');
t = CB.Ticks==value;
CB.TickLabels{t} = [CB.TickLabels{t} MarkTxt];
end
答案 1 :(得分:2)
您只需在绘图区域外添加text
,然后将其用于标记:
A = rand(15);
f=figure;
imagesc(A);
text(7,7,'X','Color','red') % Put a red X in the middle
text(17.5,size(A,1)*(1-A(7,7)),'<marker'); % Set a marker on the colour bar for the middle point
colorbar
结果是:
我还没有找到方法在颜色条上绘制标记,因为颜色条不是我可以在{{{ 1}}由于某种原因。