Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIFigure / UIAxes support doesn't work #287

Open
adamdanz opened this issue Oct 31, 2019 · 2 comments
Open

UIFigure / UIAxes support doesn't work #287

adamdanz opened this issue Oct 31, 2019 · 2 comments

Comments

@adamdanz
Copy link

adamdanz commented Oct 31, 2019

TL;DR: copyobj() cannot be used to copy UIAxes (as of r2019b).

As discussed here in Matlab Central forum, the changes recently made to support UIFigure & UIAxes doesn't work. When a UIFigure is supplied as an input, the code searches for its children and uses copyobj() to copy those components to a legacy figure. When a UIAxes is directly supplied as an input, it also uses copyobj() to copy the UIAxes to the legacy figure. The problem is that copyobj() is not supported for UIAxes. As evidence of that,

uax = uiaxes(); 
fig = figure(); 
copyobj(uax,fig)
% Error using matlab.ui.control.UIAxes/copyElement
%Functionality not supported with UIAxes. For more information, 
% see Graphics Support in App Designer. 

The error is not thrown in export_fig() because copyobj() is called from a try/catch that rethrows the error as a modified warning.

Otherwise, export_fig() is terrific!

I recently wrote a function copyUIAxes() that searches for and copies the children of a UIAxes to a new legacy axes along with the legend and colorbar if they exist. I think this is the only workaround to using copyobj() with UIAxes.

@altmany
Copy link
Owner

altmany commented Oct 31, 2019

uiaxes cannot be copied if it is created via the uiaxes() function, but it can indeed be copied if it is created via the legacy axes() function, even when it is in the uifigure:

fig = figure('Name','Legacy figure');
uif = uifigure('Name','uifigure');
uax = axes(f);  % uiaxes created in the uifigure using the legacy axes() function
hln = contourf(uax, peaks);
hlg = legend(uax);
drawnow; 
copyobj(uax, fig)  % works perfectly ok, no error

I'll investigate to check what makes the axes created in uifigure via axes() or uiaxes() so different.

@adamdanz
Copy link
Author

Yeah, this problem only pertains to copying UIAxes. I'll certainly be interested in what you find! Thanks for all of your contributions, Yair.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants