Positioning a figure

7 views (last 30 days)
Venkat Alagarsamy
Venkat Alagarsamy on 18 Mar 2011
Answered: Ayush Anand on 4 Apr 2024
Is there no way to change the position of a figure if it is docked. I am trying to place three child dockable figures into a main figure and want to set the position of the three child figures. Is that possible??

Answers (1)

Ayush Anand
Ayush Anand on 4 Apr 2024
Hi,
In MATLAB, when you dock figures MATLAB's IDE manages their layout, and direct control over the positioning of docked figures is limited, as docked figures are managed by the MATLAB Desktop, and specific positioning is typically handled through the desktop layout rather than programmatically. However, you might consider alternative approaches that give you more control over the layout, like using the "uipanel" within a figure.
Instead of using docked figures, you can create a single main figure and divide it into sections using "uipanel". Each "uipanel" can act as a container for other UI components or custom plots. This approach gives you full control over the size and position of each panel within the main figure.
mainFig = figure('Name', 'Main Figure', 'Position', [100, 100, 800, 600]);
% Create three panels within the main figure
panel1 = uipanel('Parent', mainFig, 'Position', [0, 2/3, 1, 1/3], 'Title', 'Panel 1');
panel2 = uipanel('Parent', mainFig, 'Position', [0, 1/3, 1/2, 1/3], 'Title', 'Panel 2');
panel3 = uipanel('Parent', mainFig, 'Position', [1/2, 1/3, 1/2, 1/3], 'Title', 'Panel 3');
% Example of adding a plot to a panel
axes('Parent', panel1);
plot(sin(1:0.1:25));
You can read more about "uipanel" in MATLAB here: https://www.mathworks.com/help/matlab/ref/uipanel.html
Hope this helps!

Categories

Find more on Dialog Boxes in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!