Show separate figures next to each other, not using "subplot"

26 views (last 30 days)
Hello,
I wanted to know if there is a simple way to show multiple separate figures next to each other, without overlap. I tried using the following code:
clc;
clear;
close all;
f1 = figure('units','normalized','position',[0 0 .3 .3]);
f2 = figure('units','normalized','position',[0 0 .3 .3]);
movegui(f2,[300,0]);
f3 = figure('units','normalized','position',[0 0 .3 .3]);
movegui(f3,[600,0]);
I know that I can modify the "movegui" points, but I wanted to know if another solution exist, where I do not have to manually put in the points, and the separate figures will automatically appear next to each other without overlap.
Thanks.

Accepted Answer

Walter Roberson
Walter Roberson on 15 Dec 2016
"I wanted to know if there is a simple way to show multiple separate figures next to each other, without overlap."
No.
  2 Comments
Walter Roberson
Walter Roberson on 15 Dec 2016
It is not difficult to set the Position of the figures:
figs = [f1, f2, f3]; %as many as needed
nfig = length(figs);
frac = 1/nfig;
for K = 1 : nfig
old_pos = get(figs(K), 'Position');
set(figs(K), 'Position', [(K-1)*frac, old_pos(2), frac, old_pos(4)]);
end
but I would not call that "simple".
Vivi
Vivi on 17 Mar 2023
Edited: Vivi on 17 Mar 2023
Rewrite Walter Roberson's answer,
%
% Reset the figure window location. Horizontal
%
figs = [fig_1, fig_2, fig_3, fig_4]
nfig = length(figs);
for K = 1 : nfig
old_pos = get(figs(K), 'Position')
set(figs(K), 'Position', [(K-1)*old_pos(3) old_pos(2) old_pos(3) old_pos(4)]);
end

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Tags

Products

Community Treasure Hunt

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

Start Hunting!