matlab - 子图的中心图在 Matlab 中奇怪地缩放

标签 matlab plot visualization subplot

我正在将来自 9 个不同来源的数据绘制到 Matlab 中的一个子图中。在这里你可以看到我的身影:

enter image description here

每一行代表特定变量在不同条件下的结果。所以第 1 行是变量 1,第二行变量 2 等等。无论如何,正如您从图片中看到的那样,与第二行中的其他两个相比,中心图的缩放比例很奇怪。

我使用过的代码包括命令的使用,例如:subplot(3,3,i), imagesc(data), colorbar, colormap(flipud(gray)), title('sometitle'),轴([限制])

我试图通过使用 ylim([0.5 3.5]) 设置 y 限制来修复中心图,但这没有效果......当我尝试 ylim([0 4]) 这发生了:

enter image description here

请注意,每行图中的数据具有相同大小的矩阵。第 1 行:7×7 矩阵,第 2 行:3×3 矩阵,第 3 行:4×4 矩阵。

我该如何解决这个问题? :)

感谢您的帮助!

更新:

这是我尝试使用命令后发生的事情:

subplot(3,3,5)
imagesc(data)
axis square
colorbar

enter image description here

这是一个最小的工作示例:(它显然没有给出完全相同的结果,但仍然存在类似的问题):

data11 = rand(7,7);
data12 = rand(7,7);
data13 = rand(7,7);
data21 = rand(3,3);
data22 = rand(3,3);
data23 = rand(3,3);
data31 = rand(4,4);
data32 = rand(4,4);
data33 = rand(4,4);
subplot(3,3,1)
imagesc(data11)
colorbar
colormap(flipud(gray))
title('title')
subplot(3,3,2)
imagesc(data12)
colorbar
colormap(flipud(gray))
title('title')
subplot(3,3,3)
imagesc(data13)
colorbar
colormap(flipud(gray))
title('title')
subplot(3,3,4)
imagesc(data21)
colorbar
title('title')
subplot(3,3,5)
imagesc(data22)
colorbar
title('title')
subplot(3,3,6)
imagesc(data23)
colorbar
title('title')
subplot(3,3,7)
imagesc(data31)
colorbar
title('title')
subplot(3,3,8)
imagesc(data32)
colorbar
title('title')
subplot(3,3,9)
imagesc(data33)
colorbar
title('title')

你应该得到这样的东西:

enter image description here

请注意,我分别输入了命令(command + enter、command + enter 等),然后我遇到了问题,即您在这篇文章中看到的图片。如果我复制并粘贴整个代码(整个代码 + 输入),我不会遇到任何问题...

最佳答案

我会首先尝试将每个轴的“ActivePositionProperty”设置为“位置”,请参阅 axes properties 上的文档了解详情。

 h1 = subplot(3,3,1);
 set(h1,'ActivePositionProperty','Position');

 h2 = subplot(3,3,2);
 set(h2,'ActivePositionProperty','Position');

如果这不起作用,您将需要手动为每个绘图设置位置属性。

 Margin = 0.1
 Width = 1 - 4*Margin;
 Height = 1 - 4*Margin;
 Left = [ (Margin) (2*Margin+Width) (3*Margin+2*Width) ];
 Bottom = [ (Margin) (2*Margin+Height) (3*Margin+2*Height) ];

 h1 = subplot(3,3,1);
 set(h1,'Position', [Left(1) Bottom(3) Width Height]);

 h2 = subplot(3,3,2);
 set(h1,'Position', [Left(2) Bottom(3) Width Height]);

 h3 = subplot(3,3,2);
 set(h1,'Position', [Left(3) Bottom(3) Width Height]);

 h4 = subplot(3,3,2);
 set(h1,'Position', [Left(1) Bottom(2) Width Height]);

 %Etc

关于matlab - 子图的中心图在 Matlab 中奇怪地缩放,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18225128/

相关文章:

matlab - 在数组的最大值周围查找数组

matlab - 如何为某些点绘制不同颜色的网格(MATLAB)

c++ - VTK + Cmake-> USE_VTK_RENDERING错误

ios - iOS 有像 JUNG 这样的可视化框架吗?

c++ - 对称矩阵中的线性索引

matlab - 等同符号系数

matlab - 如何在 MATLAB 中找到数组中的最大值及其索引?

ios - 生成实时录音机图

plot - GNUPLOT 如何为标签中的索引添加更多空间

javascript - 如何将 D3 数据插值/动画函数应用于动态变化的饼图