.fig file places saved figure in a different position than that originally specified

I create a figure and set it's position using set(gcf,'position'...), and then use savefig to save the figure in a file. When I then double-click on the .fig file, it comes up in a position different than the one originally specified. Is there a way to keep the figure position intact in the saved .fig file?

7 Comments

Is the position, upon opening the file, consistent with what is in the metadata? What hapens if you do,
f=gcf;
f.Position=f.Position;
Yes the position is consistent with what is in the metadata. The problem is that f.Position is no longer the position specified originally when creating the figure.
In other words, when the figure was created I used:
figure
set(gcf,'position',[1 49 2560 1341])
When I then close the figure and double-click on the .fig file, I get the following position:
get(gcf,'position')
ans =
2599 11 2544 1341
Walter, yes I am using a 2nd monitor. It creates the figure with the original coordinates on monitor 1, and then reproduces the figure in the new position on Monitor 2.

Sign in to comment.

 Accepted Answer

Some questions:
  • What release of MATLAB are you using?
  • Do you see the same issue if you set the figure position to something much smaller?
  • What is the output from get(groot,'MonitorPositions')
What I suspect may be happening is that MATLAB is trying to make sure your figure is not clipped by the edge of the screen, so it is shifting your figure to avoid hitting the edges of the screen.
Based on the position you specified, it seems like you may be trying to make the figure maximized. Can you use WindowState instead?
f = figure;
f.WindowState = "maximized";

1 Comment

Benjamin,
You were correct. Thank you, using "maximized" fixed the issue.
Release 2025b.
The issue did not occur when I made the figures smaller.
The output from get(groot,'MonitorPositions') is
>> get(groot,'MonitorPositions')
ans =
1 1 2560 1440
2561 1 2560 1440

Sign in to comment.

More Answers (0)

Categories

Find more on Printing and Saving in Help Center and File Exchange

Products

Release

R2025b

Community Treasure Hunt

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

Start Hunting!