Why does subplot size change with increasing number of plots

4 visualizaciones (últimos 30 días)
Johnny Birch
Johnny Birch el 20 de En. de 2020
Editada: KALYAN ACHARJYA el 21 de En. de 2020
I am preparing a script which will prepare and print a flexible number of plots. When i have less than 5 plots everything looks fine (attached figure 1), but when i have more that 5 plots the figure size decrease and the legenbox starts to look strange (attached figure 2). How can I fix my code so my plots and legens looks like figure regardless of the number og plots.
I will need to create a long figure depending on the number of plots, and i don't need to print out on paper. Therefore I don't need to use A4 paper. My code looks like this:
fig = figure;
set(fig,'visible','off');
m = 25 % This is the number of plots in total
for k = 1:25
plotdata = Matrix{k,1};
Legend=LegendMatrix{k,1};
subplot(m,1,k);
hold on
plot(time,plotdata,'MarkerFaceColor','auto','MarkerSize',2,'Marker','square','LineWidth',1);
plot(Xvalue,Yvalue','Marker','o','MarkerSize',2,'MarkerEdgeColor','k','Markerfacecolor','k','LineStyle','none');
set(gca,'FontSize',16);
xlim([0 mtime(end)]);
set(gca,'XTick',Xlocation);
set(gca,'XTickLabel',Xlabel);
xlabel('Time [days]');
ylabel('Fluorescence [RFU]');
title(Titles{k},'Interpreter','none');
leg = legend(Legend,'Location','southoutside','FontSize',13,'NumColumns',2);
leg.ItemTokenSize = [1,1]; % Legend line length and width
box on
hold off
end
end
set(fig,'Papersize', [19 18*m]);
set(fig,'PaperUnits','normalized');
print(fig,'-fillpage','-dpdf',fullfile(DataPath,'Full.pdf'));
end
Figure 1
figure 1.png
Figure 2
figure 2.png

Respuestas (1)

KALYAN ACHARJYA
KALYAN ACHARJYA el 21 de En. de 2020
Editada: KALYAN ACHARJYA el 21 de En. de 2020
I dont think figures are changing, just scaling the figure window as per the screen size (please check the scaling of plot axes, all are same)
Way out:
  1. Use the following
subplot(5,5,k); % Still it gives the 5 by 5 window, total 25
2. Or print the individual window with loop and later do collage / montage function
for
plot
print or save the plot
end

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Productos


Versión

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by