如何在Matlab中绘制/保存仅色条?

4

如何在Matlab中仅绘制一个颜色条,比如从-1到1的jet色卡?我需要将其保存为图像。

运行colorbar还会在颜色条旁边绘制一个空轴。


你能发布一下你目前的代码吗? - Acorbe
@Acorbe 在这里:colorbar。或者 colorbar; print mybar - Tim
3个回答

8
这个怎么样?
colorbar
axis off

编辑:

如果您想完全控制色条的宽度和位置,则可以执行以下操作:

fig1=figure;
left=100; bottom=100 ; width=20 ; height=500;
pos=[left bottom width height];
axis off
colorbar([0.1 0.1  0.7  0.8]);
set(fig1,'OuterPosition',pos) 

enter image description here


你说得对!我会这样做,然后用 convert 裁剪图像。 - Andreas

4

2

受bla的启发,这里提供了更多调整选项的答案。(Rep<50表示无法评论,抱歉!)

fig1=figure;
axis off
colormap(gray(100));
caxis([-1 1]);
h = colorbar([0.1 0.1  0.8  0.7],...
  'location','Southoutside',...
  'XTick',[-1 -0.5 0 0.5 1]);
set(h,'OuterPosition',[0.1 0.1 0.8 0.8]);

Grey Colorbar from -1 to 1


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接