Problem with different sizes in subplot

조회 수: 4 (최근 30일)
Chris
Chris 2015년 10월 3일
답변: Jan 2015년 10월 4일
%crosspost from Newsgroup
Hello everyone!
I want to plot a series of data maps (XY-t maps), 68 time steps of a 84x3 matrix. The aspect ratio of the XY plot is supposed to be 1:1 (equal step size in X and Y), but I can't get this fixed while maintaining the same size for all 68 XY plots. When I fix the aspect ratio of the individual (sub-)plot (daspect), then the size of a variable amount of XY plots gets automatically rescaled (best seen when changing the figure size with the mouse cursor, see example code). Without daspect, I can't be sure that both axis have the right ratio.
I can change the figure size by hand (mouse cursor), the individual subplots will change size and also be perfectly aligned at some point, but that is no sufficient solution for me.
Any idea to resolve my dilemma?
Best regards, CL
Edit: It has to do something with auto-resizing and the large number of subplots. Setting the number of subplots to for example 10 yields a prefect plot. Thus, how do I set the right size for my subplots or at least deactivate the auto-scaling?
Example:
Example code:
%data
m=1;
n=68;
data=rand(84,3,n);
%plotting
h=figure('units','normalized','position',[0.1 0.1 0.7 0.4]);
for i = m:n
subplot(1,n,i);
imagesc(data(:,:,i));
%remove tick marks/label
set(gca, 'XTickLabel', [], 'XTick', [],'YTickLabel', [],'YTick',[]);
%aspect ratio
daspect([1 1 1]);
%add title every few columns
if mod(i,5)==0
title('test')
else
end
end
colorbar;
  댓글 수: 1
Jan
Jan 2015년 10월 4일
I get the same behavior with R2011b, the different renderers and without the titles.

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2015년 10월 4일
It seems like this is related to the number of pixels available for a single subplot, such that it is a rounding problem finally.
Either use a single axes and draw the images at different positions. Or use a patch or surf object for each axes, see:

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

제품

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by