UItabgroup does not save position within UIfigure using saveas or savefig

106 ビュー (過去 30 日間)
Bennett
Bennett 2024 年 11 月 1 日 13:01
コメント済み: Bennett 2024 年 11 月 11 日 13:25
I am having issues using saveas with UItabgroups. It seems the position of the uitabgroup is not saved when using saveas, and defaults to a smaller portion of the figure when opened again. I have seen a few similar questions with no concrete answers, a few users had suggested it's a "bug" but all other UIfigure properties I add save fine.
%initialize figure
hfig1 = uifigure;
hfig1.WindowState = 'maximized';
htabgroup = uitabgroup(hfig1,"SelectionChangedFcn",@displaySelection);
htabgroup.Position = [0 0 1600 800];
%% Button for save
save_btn = uibutton(hfig1,"Text","Save Figure","Position",[1610 740 75 25]);
save_btn.ButtonPushedFcn = {@saveFig,hfig1};
function saveFig(src,event,hfig)
%Get new file name
prompt2 = {'Would you like to save the figure? If yes, please enter desired name below, otherwise hit okay'};
dlgtitle2 = 'Input';
fieldsize2 = [1 150];
definput2 = {'Figure_file_name'};
fig_file_cell = inputdlg(prompt2,dlgtitle2,fieldsize2,definput2);
%Covnert file name and save
fig_file_save = convertCharsToStrings(char(fig_file_cell));
saveas(hfig,fig_file_save,'fig')
end
  6 件のコメント
Walter Roberson
Walter Roberson 2024 年 11 月 6 日 21:41
You did not answer the question of why you are using saveas() instead of savefig() ?
Bennett
Bennett 2024 年 11 月 7 日 13:06
Hi @Walter Roberson, apologies for missing that. No particular reason, after your intial comment I tried using savefig and it did not work either.

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

採用された回答

Madheswaran
Madheswaran 2024 年 11 月 8 日 9:43
Hello @Bennett
The problem you're experiencing with saving figures appears to be resolved in Update 6 of MATLAB R2022a. I recommend updating your MATLAB to the latest version. You can find the MathWorks documentation on updating an existing installation here: https://mathworks.com/help/matlab/matlab_env/check-for-software-updates.html
Hope this helps!
  1 件のコメント
Bennett
Bennett 2024 年 11 月 11 日 13:25
Hi @Madheswaran this fixed all the issues I had. Thanks for the update advice!

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

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by