Effacer les filtres
Effacer les filtres

How to reduce a figure size within the plotting area and adjuste it to be centralized?

17 vues (au cours des 30 derniers jours)
I want to to adjust the plotting area of this figure,
so, when I save the figure it will have it with a reduced white area arounding it.
I have tried the following
f1 = figure(1);
FigSize12 = get(f1,'position');
% f1.Units = 'pixels';
f1.Position = [600 400 FigSize12(3) FigSize12(4)/2.75];
And I get:
But, doing that I am not able to reduce the width and my figure is not centralized within the plotting area. As I need to do this procedure for many figures I need also to be able to control the length and the width using the figure properties.
  4 commentaires
Walter Roberson
Walter Roberson le 27 Juil 2019
Adjusting the Position property does not change the PaperPosition property.
AXL le 27 Juil 2019
set(gca,'LooseInset', max(get(gca,'TightInset'), 0.05))
I got centered figures, but sometimes that's not you want!

Connectez-vous pour commenter.

Réponse acceptée

Jyothis Gireesh
Jyothis Gireesh le 2 Août 2019
To reduce the figure size and to centralize it, you may make use of the manual option of the PaperPosition property of the figure. This allows us to change the position and dimensions of the printed figure.
The following code snippet illustrates the usage.
set(gcf, 'PaperPositionMode', 'manual');
set(gcf, 'PaperUnits', 'inches');
set(gcf, 'PaperPosition', [2 1 4 2]);
It sets the figure size to a width of 4 inches and height of 2 inches, with the origin of the figure positioned 2 inches from the left edge and 1 inch from the bottom edge.
You may also use the following link to get a detailed explanation about the PaperPosition property.
  1 commentaire
Walter Roberson
Walter Roberson le 2 Août 2019
When you set the PaperPosition property yourself then matlab automatically sets PaperPositionMode to manual

Connectez-vous pour commenter.

Plus de réponses (0)


En savoir plus sur Graphics Objects dans Help Center et File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by