MATLAB Answers

exportgraphics: adding a margin

32 views (last 30 days)
dormant
dormant on 21 Jun 2021
Commented: Fatemeh Sadeghihassanabadi on 11 Oct 2021 at 14:33
Is it possible to add a margin to figures saved using the exportgraphics function?
It crops a tad too tightly for my needs.

Answers (2)

Paul Wintz
Paul Wintz on 15 Sep 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].
  1 Comment
Fatemeh Sadeghihassanabadi
Fatemeh Sadeghihassanabadi on 11 Oct 2021 at 14:33
Thanks @Paul Wintz, I had the same problem, this is the best solution for it.

Sign in to comment.


Kiran Felix Robert
Kiran Felix Robert on 24 Jun 2021
Hi Dormant,
If you are trying to export multiple sub-images/plots onto a single figure, you can explore the tiledlayout to introduce spacing using the 'TileSpacing' Name-Value pair.
  1 Comment
Paul Wintz
Paul Wintz on 15 Sep 2021
This doesn't answer the question. How do we adjust the margins on the outside of a figure saved with exportgraphics?

Sign in to comment.

Tags

Products


Release

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by