Matlab shrinking subplot graphs when running the code
16 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Bjorn Gustavsson
el 17 de Jul. de 2020
Would it be possible for you to share the data producing your problematic figure?
Respuestas (1)
Bjorn Gustavsson
el 16 de Jul. de 2020
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 comentarios
Bjorn Gustavsson
el 16 de Jul. de 2020
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.
Ver también
Categorías
Más información sobre Subplots en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!