如何在子图中设置颜色条大小和标签?
How to set the colorbar size and label in a subplot?
我有以下子图,要打印我正在使用 imagesc
命令的图像。我怎样才能使颜色条的大小与两个图相匹配,并在颜色条旁边(水平对齐)写上“[m]”或“[deg]”标签?
f_prova3 = figure();
s1 = subplot(1,2,1); imagesc(DEM); axis equal; axis off;
hb1 = colorbar('location','eastoutside');
s2 = subplot(1,2,2); imagesc(slopeMap_int); colormap jet, axis equal;axis off;
hb2 = colorbar('location','eastoutside');
抱歉,我好像不能直接添加图片。感谢您的帮助
您可以添加axis tight
来调整高度并使用标签属性来调整标签:
DEM = magic(5);
slopeMap_int = magic(5);
f_prova3 = figure();
s1 = subplot(1,2,1); imagesc(DEM); axis equal; axis tight; axis off;
hb1 = colorbar('location','eastoutside');
s2 = subplot(1,2,2); imagesc(slopeMap_int); colormap jet; axis equal; axis tight; axis off;
hb2 = colorbar('location','eastoutside');
hb1.Label.String = '[m]';
hb1.Label.Rotation = 0;
hb1.Label.HorizontalAlignment = 'Left';
hb2.Label.String = '[deg]';
hb2.Label.Rotation = 0;
hb2.Label.HorizontalAlignment = 'Left';
我在 Matlab R2016a 中测试过。
我有以下子图,要打印我正在使用 imagesc
命令的图像。我怎样才能使颜色条的大小与两个图相匹配,并在颜色条旁边(水平对齐)写上“[m]”或“[deg]”标签?
f_prova3 = figure();
s1 = subplot(1,2,1); imagesc(DEM); axis equal; axis off;
hb1 = colorbar('location','eastoutside');
s2 = subplot(1,2,2); imagesc(slopeMap_int); colormap jet, axis equal;axis off;
hb2 = colorbar('location','eastoutside');
抱歉,我好像不能直接添加图片。感谢您的帮助
您可以添加axis tight
来调整高度并使用标签属性来调整标签:
DEM = magic(5);
slopeMap_int = magic(5);
f_prova3 = figure();
s1 = subplot(1,2,1); imagesc(DEM); axis equal; axis tight; axis off;
hb1 = colorbar('location','eastoutside');
s2 = subplot(1,2,2); imagesc(slopeMap_int); colormap jet; axis equal; axis tight; axis off;
hb2 = colorbar('location','eastoutside');
hb1.Label.String = '[m]';
hb1.Label.Rotation = 0;
hb1.Label.HorizontalAlignment = 'Left';
hb2.Label.String = '[deg]';
hb2.Label.Rotation = 0;
hb2.Label.HorizontalAlignment = 'Left';
我在 Matlab R2016a 中测试过。