3 matlab plot axis image scale
我使用以下代码行来绘制图像:
for t=1:subplotCol
subplot(subplotRow,subplotCol,t)
imagesc([1 100],[1 100],c(:,:,nStep*t));
colorbar
xlabel('X-axis')
ylabel('Y-axis')
title(['Concentration profile at t_{',num2str(nStep*t),'}'])
subplot(subplotRow,subplotCol,subplotCol+t)
hold on;
plot(distance,gamma(:,1,t),'-ob');
plot(distance,gamma(:,2,t),'-or');
plot(distance,gamma(:,3,t),'-og');
xlabel('h');ylabel('\gamma (h)');
legend(['\Theta = ',num2str(theta(1))],...
['\Theta = ',num2str(theta(2))],['\Theta = ',num2str(theta(3))]);
end
Run Code Online (Sandbox Code Playgroud)
我得到以下带有图像的子图:

如您所见,第一行中的图像现在在X轴和Y轴上均匀缩放(Y轴比X轴长),即使第一行上每个图像的图像矩阵大小为100x100.
有人可以帮助我们如何使第一行中的图像看起来像正方形而不是我目前得到的矩形.谢谢.
使用dataAspectRatio轴的属性,并将其设置为[1 1 1]
%# create a test image
imagesc(1:10,1:10,rand(10))
Run Code Online (Sandbox Code Playgroud)

%# you should use the handle returned by subplot
%# instead of gca
set(gca,'dataAspectRatio',[1 1 1])
Run Code Online (Sandbox Code Playgroud)
