cropFigure - makes the axis tight inside the figure

Generates a new figure without the extra space between the axes and the figure boundary.
142 Downloads
Aktualisiert 1. Nov 2019

Lizenz anzeigen

This function crops annoying borders from the figures. Useful for using before exporting as a PDF with the saveas command from MATLAB.

Example: simple figure with padding
fh = figure;
plot(1:100,cos(1:100));
cropFigure(fh,10); % adds a padding of 10/2 pixels to each side of the figure (10 pixels horizontally and 10 vertically)

Example: figure with many panels:

subplot(2,2,1);plot(1:100,cos(1:100));
subplot(2,2,2);plot(1:100,cos(1:100));
subplot(2,2,3);plot(1:100,cos(1:100));
subplot(2,2,4);plot(1:100,cos(1:100));
cropFigure

Kompatibilität der MATLAB-Version
Erstellt mit R2018a
Kompatibel mit R2008a und späteren Versionen
Plattform-Kompatibilität
Windows macOS Linux
Kategorien
Mehr zu Printing and Saving finden Sie in Help Center und MATLAB Answers

Community Treasure Hunt

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

Start Hunting!
Version Veröffentlicht Versionshinweise
2.0.0

Fixed the cropping behavior when there are hidden elements.

1.0.0