exportgraphics: adding a margin
118 views (last 30 days)
Paul Wintz on 15 Sep 2021
Edited: Paul Wintz on 18 Nov 2021
You can force exportgraphics to export the entire figure by drawing an white rectange around it with the command
annotation('rectangle',[0 0 1 1],'Color','w');
To adjust the margins, change the dimensions [0 0 1 1].
As noted by @David Walwark in the comments, the plot will not be interactive while it is annotated. To restore interactivity, delete the annotation after calling exportgraphics.
a = annotation('rectangle',[0 0 1 1],'Color','w');
% -> Save figure here <-