You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
The text was updated successfully, but these errors were encountered:
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.
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,
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.
The text was updated successfully, but these errors were encountered: