I have a UIAxes in an app that I want to save as a .fig file so I'm using this:
placeholder=figure();
placeax=copyobj(app.UIAxes,placeholder,"legacy");
savefig(placeax,[app.folder,'\Results\',app.model,' - nodeview.fig']);
The new figure is created and the graph is copied across but I can't see it. What I mean by that is when hovering my mouse over I can see that the axes and the points are there but the graphic doesn't show up.
Any suggestions as to why I can't see the graph?

3 件のコメント

dpb
dpb 2026 年 6 月 4 日 14:42
The target is an "ordinary" figure into which you're placing a new UIAxes. Try into a UIFigure instead
Timothy
Timothy 2026 年 6 月 4 日 15:16
I have the same issue that I can't save a UIfigure as a .fig file - at least not using savefig. Also it doesn't seem to slove the issue anyway
dpb
dpb 2026 年 6 月 4 日 16:08
Try something on the order of
placeholder=figure('Visible','off');
placeax=copyobj(app.UIAxes.Children,axes(placeholder),'legacy');
savefig(placeholder,fullfile(app.folder,'\Results\',app.model,' - nodeview.fig'));
delete(placeholder); % optional
Nota bene: Untested...
For figures in app developer apps which reside in UIFigure-land, look at exportgraphics

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

 採用された回答

dpb
dpb 2026 年 6 月 4 日 16:30

1 投票

Try <copyUIAxes> by @Adam Danz (from before he moved to TMW) in FEX

8 件のコメント

Timothy
Timothy 2026 年 6 月 8 日 13:09
I can't seem to get that to work at all. It seems like a super simple solution but the new figure doesn't copy across the axes any data
dpb
dpb 2026 年 6 月 8 日 14:37
Hmmmm...Adam is pretty good and I noticed he cast a vote to use his submission so apparently he is of the opinion it should still work.
Just for testing that it isn't something else going on, can you create a simple minimal working example that reproduces the problem that can attach? Unfortunately, can't run anything with uifigure on the forum, but it would provide a consistent working base as well as a potential submission to Mathworks if this eventually comes down to a formal support request.
Timothy
Timothy 2026 年 6 月 8 日 15:42
here is a super simple example with just a random graph but it doesn't work either way
Timothy
Timothy 2026 年 6 月 8 日 15:44
編集済み: dpb 2026 年 6 月 8 日 16:45
Sorry that's probably not helpful, here's the code
% Create UI figure
fig = uifigure('Name', 'Random Data Plot');
% Create UI axes inside the figure
ax = uiaxes(fig);
% Optional: set position [x y width height]
ax.Position = [50 50 500 300];
% Generate random data
x = 1:100;
y = rand(1,100); % Random values between 0 and 1
% Plot data on uiaxes
plot(ax, x, y, 'b-', 'LineWidth', 1.5);
% Add labels and title
title(ax, 'Random Data');
xlabel(ax, 'Index');
ylabel(ax, 'Value');
grid(ax, 'on');
placeholder=figure();
copyUIAxes(ax,placeholder);
dpb
dpb 2026 年 6 月 8 日 16:47
OK, thanks. That destroys the idea there might be something else going on, though.
I've got other commitment at the moment but will try to get back later on and see if can figure out what might be going on.
Walter Roberson
Walter Roberson 2026 年 6 月 8 日 17:43
Datapoint:
I do not see the noted behaviour on MacOS Tahoe Intel with R2025b. In my tests, the copied figure is fully visible.
Timothy
Timothy 2026 年 6 月 9 日 8:52
You know what, I restarted my computer just as a last resort and now it works so I guess just my build was buggy. Thanks
dpb
dpb 2026 年 6 月 10 日 19:44
Twilight Zone stuff happens more often than we might think...

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

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeEnvironment and Settings についてさらに検索

製品

リリース

R2025b

質問済み:

2026 年 6 月 4 日 13:50

コメント済み:

dpb
2026 年 6 月 10 日 19:44

Community Treasure Hunt

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

Start Hunting!

Translated by