- Use the following
Why does subplot size change with increasing number of plots
3 views (last 30 days)
Show older comments
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 2
0 Comments
Answers (1)
KALYAN ACHARJYA
on 21 Jan 2020
Edited: KALYAN ACHARJYA
on 21 Jan 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:
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
0 Comments
See Also
Categories
Find more on Line Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!