kb:programming:matlab:figure-outside-screen
Figures placed outside screen resolution
I disconnected my Windows laptop from my working monitor (in `Extend` mode), and plugged it into classroom projector for teaching. Then, my plotting code in MATLAB just doesn't bring up any figure window any more.
If I unplug the projector and re-plug in, sometimes the figure will show up.
Some figures will show up normally.
Cause: The figure is placed outside the current monitor size.
Solution: There are multiple ways.
- Use `set(groot, 'DefaultFigurePosition', [0, 0, width, height])` to change the default position of the figure, and re-plot them. This is not documented officially.
- `Shift + right click` on the figure window, select `Move`, then, IMPORTANT, press `Left` or `Right` key on the keyboard. The window should show up now when moving your cursor.
- Change Windows resolution to a different set and change back, this brings all windows back.
- All other tricks to bring windows outside the screen back should work too.
Longer version: Using `get(groot, 'DefaultFigurePosition')` to check the default position for the figure. This value seems to be initialized outside the resolution of the projector (1080p / 125%). This value is not updated when I change to a different monitor or even just disconnect the monitor, unless I restart the MATLAB process (another bad design of MATLAB).
kb/programming/matlab/figure-outside-screen.txt · Last modified: 2024/07/31 16:10 by hao