Matlab shrinking subplot graphs when running the code
16 次查看(过去 30 天)
显示 更早的评论
Everytime I run my code, the graphs I have shrink.
figure(100);clf;
or = [0.8500, 0.3250, 0.0980];
ye = [0.9290, 0.6940, 0.1250];
bl = [0, 0.4470, 0.7410];
vec = [or;ye;bl];
clr = 'rgb';
sz = 14;
yname(1).s = '\mu_s [cm^{-1}]';ytitle(1).s = 'Scattering';
yname(2).s = 'g [-]';ytitle(2).s = 'Anisiotropy';
yname(3).s = '\mu_s'' [cm^{-1}]';ytitle(3).s = 'Reduced Scattering';
ymax = [3000 1 400];
for k=1:3
subplot(3,1,k)
for j=1:length(diadia)
plot(lambdalambda, musgp(:,j,k),'-','color',vec(j,:),'linewidth',1)
hold on
y = ymax(k); dy = y/10; x = mean(lambdalambda);
text(x,y-dy*j,sprintf('dia = %0.3f um', diadia(j)), ...
'fontsize',sz, 'color',vec(j,:))
end%j
set(gca,'fontsize',sz)
xlabel('wavelength \lambda [\mum]')
ylabel(yname(k).s)
title(ytitle(k).s, 'fontsize',14)
end%k
is there a way I can make it so it does not shrink, or how would I separate the figure into three plots if this is not possible?
3 个评论
Bjorn Gustavsson
2020-7-17
Would it be possible for you to share the data producing your problematic figure?
回答(1 个)
Bjorn Gustavsson
2020-7-16
Sometimes that (used to) happen, as far as I understood it had something to do with repeated plotting (possibly with titles and labels). You might avoid that by plotting all curves at once. Perhaps something like this:
for k=1:3
subplot(3,1,k)
j=1:length(diadia);
phK{k} = plot(lambdalambda,squeeze(musgp(:,j,k)),'-','color','linewidth',1);
hold on
y = ymax(k); dy = y/10; x = mean(lambdalambda);
text(x,y-dy*j,sprintf('dia = %0.3f um', diadia(j)), ...
'fontsize',sz, 'color',vec(j,:))
set(gca,'fontsize',sz)
xlabel('wavelength \lambda [\mum]')
ylabel(yname(k).s)
title(ytitle(k).s, 'fontsize',14)
end%k
for k = 1:3,
for j = 1:size(phK{k})
set(phK{k}(j),'color',vec(j,:));
end
end
HTH
4 个评论
Bjorn Gustavsson
2020-7-16
Hm, (when I encounter this problem, I typically solve it irritated and on an exception-by-exception base so no record of what have worked...) what if you try to remove all the titling and labeling (or at least the resising of everything) and put that in separately at the end?
There is also a vague tingling of a memory that I've managed to the axes to get in shape by manually resizing the figure window.
Another, design-take on your figure: since you have the same range in wavelength in all subplots, you might consider only adding the xlabel to the bottom subplot - that will help save you some real-estate for the plots. Now, this is not my task or place to question your design/taste, but this is how I get more graph and less repeated text in my figures.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Subplots 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!