How to pop-out figure from tiled figure in editor (2022b)

On a prior version of matlab, there was a icon that poped up in the tiled figure that allowed me to pop a tiled figure into its own window. Now it just saves an image of it. I want to zoom in and maximize my view in the figure editor.
The new icon is shown here, the old one did as I wanted, was in the same position on the pop up axis menu.
Thanks for your help!

4 Comments

Thank you for bringing this to notice. Could you please tell which version of MATLAB you used, which enabled you to pop-out figure from the tiled layout? I can see that in the latest version I am unable to do so.
I think it was 2020B it could have been 2020A. I will ask a co-worker tomorrow to see if he still has the old vesion installed.
Hi,
I tried out versions of MATLAB back till 2019b but couldn't find the feature you are talking about. Kindly recheck it and confirm the version if you find it.
Thanks, I need to find someone who has older version of matlab installed... (corportate computer I can't install it myself).

Sign in to comment.

 Accepted Answer

I don't believe there was ever an icon that allowed you to pop-out one axes from within figure and create a new figure, but it wouldn't be terribly difficult to implement such a feature for yourself by customizing the axes toolbar.
For example:
f = figure;
for n = 1:6
ax = nexttile();
plot(sin(linspace(0,2*pi,100)+(pi*n/3)))
% Create a custom toolbar with no buttons
% You can keep any of the buttons you want to keep.
tb = axtoolbar(ax);
% Create a custom export button.
btn = axtoolbarbtn(tb, 'push', 'Icon', 'export');
% When the button is pushed, use copyobj to copy the axes into a new
% figure
btn.ButtonPushedFcn = @(~,e) set(copyobj(e.Axes,figure),'OuterPosition',[0 0 1 1]);
end

5 Comments

Here is a more complicated version that uses a local helper function to fix some of the layout issues you see with the simpler version. This version needs to be run from a script.
f = figure;
for n = 1:6
ax = nexttile();
plot(sin(linspace(0,2*pi,100)+(pi*n/3)))
% Create a custom toolbar with no buttons
% You can keep any of the buttons you want to keep.
tb = axtoolbar(ax);
% Create a custom export button.
btn = axtoolbarbtn(tb, 'push', 'Icon', 'export');
% When the button is pushed, use copyobj to copy the axes into a new
% figure
btn.ButtonPushedFcn = @copyToNewFigure;
end
function copyToNewFigure(~,e)
f = figure;
t = tiledlayout(f,1,1);
ax = copyobj(e.Axes, t);
ax.Layout.Tile = 1;
end
And yet another version that fixes the layout issue and doesn't use a local function.
f = figure;
for n = 1:6
ax = nexttile();
plot(sin(linspace(0,2*pi,100)+(pi*n/3)))
% Create a custom toolbar with no buttons
% You can keep any of the buttons you want to keep.
tb = axtoolbar(ax);
% Create a custom export button.
btn = axtoolbarbtn(tb, 'push', 'Icon', 'export');
% When the button is pushed, use copyobj to copy the axes into a new
% figure
btn.ButtonPushedFcn = @(~,e) copyobj(e.Axes,tiledlayout(figure,'flow'));
end
Works great!
The comment indicates that I can keep the original buttons, how can I do that? I still would like keep datatips and zoom functions.
Thank you Benjamin!
If you want to keep the original toolbar buttons, you just need to specify them in a list when you call axtoolbar. Check the doc page for axtoolbar for more details.
tb = axtoolbar(ax,{'datacursor','zoomin','zoomout'});
Thanks again, now my application is just how I want it to work, with only a few lines of code changed.

Sign in to comment.

More Answers (0)

Categories

Find more on Environment and Settings in Help Center and File Exchange

Products

Release

R2022b

Community Treasure Hunt

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

Start Hunting!