MATLAB Answers

How can I copy figure to UIAxes?

21 views (last 30 days)
Yaren Sever
Yaren Sever on 6 Jul 2020
Answered: Walter Roberson on 6 Jul 2020
I created figure which includes gramm graphs. I want to copy this figure to UIAxes component. I tried copyObj but I couldn't solve it.

  6 Comments

Show 3 older comments

Sign in to comment.

Answers (2)

Mehmed Saad
Mehmed Saad on 6 Jul 2020
a = uiaxes;
b = getframe(gca);
imshow(b.cdata,'Parent',b)
There might be some quality issues

  0 Comments

Sign in to comment.


Walter Roberson
Walter Roberson on 6 Jul 2020
Use imhandles() on the figure that is showing the gramm object.
You can now copyobj() the resulting handle(s) to a uiaxes that is part of a uifigure. You can also, if appropriate, set the Parent property of the image handles to be the uiaxes.
ufig = uifigure();
uax = axes('Parent', ufig);
tfig = figure();
tax = axes('Parent', tfig);
image('Parent', tax); %there is a default image.
imh = imhandles(tfig); %pretending we do not have the image handle easily available
imh.Parent = uax; %move the image from the traditional axes to the uiaxes.

  0 Comments

Sign in to comment.