如何在Matlab中用Colorbar控制图形的相对大小?

时间:2016-03-02 17:41:09

标签: matlab matlab-figure colorbar

我正在尝试将图像的图形排列在图像中,其中图像具有颜色条。颜色条使轴水平偏移。 我的直观方法是将数字大小固定在某些东西上,就像在Gnuplot中使用纸张大小一样。但是,不确定哪个最合适。

在Matlab的全屏模式下调整缩放比例?

我想保持这两个数字之间的关系。由于某种原因,我不能在第一个数字中使用squareform,而在后一个数字中我可以使用figure ax2=subplot(2,2,2); plot(mat2gray(pdist(data, 'correlation'))); title('Corr pdist'); cbar2 = colorbar(ax2); xlim([0 size(mat2gray(pdist(data, 'correlation')),2)]); set(cbar2, 'Visible', 'off'); ax4=subplot(2,2,4); imshow(squareform( mat2gray(pdist(data, 'correlation')), 'tomatrix') ); colormap('parula'); colorbar; title('Square Corr pdist'); 。 代码

SELECT B.* 
FROM 
A INNER JOIN B 
USING (X,Y)
WHERE A.id = 1234

在Matlab的全屏模式下输出中的错误缩放,您在其中看到colorbar方法不足以保持关系<{3}}中关于如何在Matlab中使用Colorbar控制图形的相对大小的关系?

here

默认视图时输出中的右缩放

enter image description here

如何在Matlab的全屏模式下保持数字的方形视图?

1 个答案:

答案 0 :(得分:4)

我只是为顶轴创建一个颜色条,并将可见性设置为关闭。

figure;
ax1 = subplot(2,1,1);
ax2 = subplot(2,1,2);

cbar1 = colorbar(ax1);
cbar2 = colorbar(ax2);

set(cbar1, 'Visible', 'off')

enter image description here

这样做的好处是,在调整图形大小等时,您将获得一致的行为,因为两个轴的大小和位置将以相同的方式呈现。

您需要记住的另一件事是保持轴在所有方面都相同。因此,例如,如果底部轴中有图像(使用imshow),默认情况下MATLAB将轴设置为正方形。为了使您的顶部情节也变为正方形,您需要使用axis square。然后他们会继续排队。

axis(ax1, 'square')

enter image description here