Figure & Subplot: Getting rid of needless white space
8 views (last 30 days)
Show older comments
Hello, I am currently trying to find out why there is excessive white space left and right of the plots when the spacing was just fine for a single plot in the figure. Please excuse the lengthy example. I am unsure what exactly causes the strange spacing. Hopefully you can give me hint, what to look into. (as at the moment I am cropping it manually..)
btw - Loose and TightInset did not work for me yet, but it seems quite possible that I implemented them in a wrong way as the figure was either empty or cut off vertical space (instead of horizontal).
Best Regards
fig = figure();
set(fig,'color', none,'position',[100 100 1200 400]);
set(gca,'LooseInset',get(gca,'TightInset')) % my try to crop the figure
subplot(1,2,1)
p = plot(x, y1, x, y2, x, y3, x, y4);
ylabel('label1 (unit)', 'interpreter', 'latex', 'fontsize', 20)
xlabel('label2 (unit)', 'interpreter', 'latex', 'fontsize', 20)
set(gca, 'fontsize', 20);
set(gca, 'XTick', [0:2.5:10], 'xlim', [0 10]);
set(gca, 'YTick', [0:25:100], 'ylim', [0 100]);
grid on
subplot(1,2,2)
q = plot(x2, y5, x2, y6, x2, y7, x2, y8);
ylabel('label1 (unit)', 'interpreter', 'latex', 'fontsize', 20)
xlabel('label2 (unit)', 'interpreter', 'latex', 'fontsize', 20)
set(gca, 'fontsize', 20);
set(gca, 'XTick', [0:2.5:10], 'xlim', [0 10]);
set(gca, 'YTick', [0:100:400], 'ylim', [0 400]);
grid on
save_fig(fig, 'test');
0 Comments
Answers (1)
See Also
Categories
Find more on Subplots 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!