Grouping Figures separately into windows and tabs

527 ビュー (過去 30 日間)
AwedBy Matlab
AwedBy Matlab 2014 年 10 月 4 日
編集済み: Daniel 2024 年 1 月 18 日
I have 4 plots to make, of vectors y1, y2, y3 and y4, all as a function of a vector x. I would like the first two plots to be grouped as tabs within a single Figure window, and the next two plots also grouped as tabs but in a separate window.
I tried this code:
figure
set(0,'DefaultFigureWindowStyle','docked')
plot(x,y1)
plot(x,y2)
figure
set(0,'DefaultFigureWindowStyle','normal')
plot(x,y3)
set(0,'DefaultFigureWindowStyle','docked')
plot(x,y4)
..but once tab grouping is re-enabled, plots are just added as new tabs appended to the old window rather than in a new window.
I played around with the order of the commands above but it didnt help. If anything, I only managed to get one of the plots overwritten in the same window. Please note i don't want any of the graphs to overlap, therefore "hold on" would not help.
Any suggestions? Thanks!
  3 件のコメント
Ajay krishna Vasanthakumar
Ajay krishna Vasanthakumar 2020 年 10 月 30 日
Hello can someone help how to change the tab position from top to left programtically in the docked figures
Mojgan Vaziri
Mojgan Vaziri 2023 年 7 月 17 日
@Ajay krishna Vasanthakumar I also wonder that. Do you have an answer to that question by now?

サインインしてコメントする。

回答 (4 件)

Jan
Jan 2017 年 8 月 28 日
編集済み: Jan 2017 年 8 月 28 日
You can create a window, which contains several docked figures:
desktop = com.mathworks.mde.desk.MLDesktop.getInstance;
myGroup = desktop.addGroup('myGroup');
desktop.setGroupDocked('myGroup', 0);
myDim = java.awt.Dimension(4, 2); % 4 columns, 2 rows
% 1: Maximized, 2: Tiled, 3: Floating
desktop.setDocumentArrangement('myGroup', 2, myDim)
figH = gobjects(1, 8);
bakWarn = warning('off','MATLAB:HandleGraphics:ObsoletedProperty:JavaFrame');
for iFig = 1:8
figH(iFig) = figure('WindowStyle', 'docked', ...
'Name', sprintf('Figure %d', iFig), 'NumberTitle', 'off');
drawnow;
pause(0.02); % Magic, reduces rendering errors
set(get(handle(figH(iFig)), 'javaframe'), 'GroupName', 'myGroup');
plot(1:10, rand(1, 10));
end
warning(bakWarn);
or after hitting the icon on the top right to move all figures inside tabs (or prgrammatically: by desktop.setDocumentArrangement('myGroup', 1, myDim) ) :
This uses heavily undocumented commands. It works since at least 2009a (except for the gobjects()), but I assume I should use the EDT instead of the magic pause(0.02). I hope that Yair will improve this snippet.
  16 件のコメント
Kristoffer Florvaag-Dybvik
Kristoffer Florvaag-Dybvik 2023 年 1 月 31 日
Thank you!
Daniel
Daniel 2024 年 1 月 17 日
編集済み: Daniel 2024 年 1 月 18 日
@Jan Got this warning are there any more stable ways?
Warning: The JavaFrame figure property will be removed in a future release. For more information see UI Alternatives for MATLAB
Apps on mathworks.com.

サインインしてコメントする。


Azzi Abdelmalek
Azzi Abdelmalek 2014 年 10 月 4 日
Use hold on
figure
set(0,'DefaultFigureWindowStyle','docked')
plot(x,y1)
hold on
plot(x,y2)
  2 件のコメント
AwedBy Matlab
AwedBy Matlab 2014 年 10 月 4 日
No, that doesn't do what I want. Please read my question again. "hold on" is not what I need, as I do not want overlapping plots. i want the first 2 plots grouped as tabs, and same for the net 2 plots but in a new window
Jrod H
Jrod H 2022 年 4 月 1 日
Well, the set( ) function did exactly what I wanted!! Works great. Do you know what command to pass to get the windows to display in "Tile" mode rather than as tabs?

サインインしてコメントする。


Image Analyst
Image Analyst 2014 年 10 月 4 日
MATLAB does not have a tab control. The best you can do is a panel. Put your stuff into panels and then set the visibility of each panel on or off using set(hPanel, 'Visibility', 'off') that is in the callback of something like checkboxes or pushbuttons that you put into an array atop where the panels go.
Alternatively you could use a new figure for each set of plots (I'd probably not have more than about an array of 3 by 4 on each window) and use subplot() to plot into the desired plot on that figure. Let me know if you don't know how to do this and it's what you want.
  1 件のコメント
AwedBy Matlab
AwedBy Matlab 2014 年 10 月 4 日
Thanks Image Analyst! In this case I'd much prefer having full-screen figures, but separated by tabs or windows, as I explained, rather than having them as small subplots.
I know Matlab doesnt offer tab control as such, however when you just need figures across tabs of a single window, the set(0,'DefaultFigureWindowStyle','docked') command does the job quite well. It's strange that switching between docked and normal doesnt do what I expected it to, i.e. start a new window and then tab the new figures ito that new window

サインインしてコメントする。


Matthew
Matthew 2017 年 6 月 19 日
I'm not too familiar, but I think using the "docked" approach to getting these tabbed figures, you will not be able to accomplish what you are trying to do. Any "docked" figures will all end up in one top level figures window. Any "normal" figures can exist on their own. You can not have two figure windows each with docked figures.
I think you could accomplish what you are trying to do with uifigures, but they may lack other capabilites you are looking for. See "Graphics Support in App Designer" in the matlab help for discussion of what uifigures do and do not support.

カテゴリ

Help Center および File ExchangePrinting and Saving についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by