Display a figure on a GUI axes?
Show older comments
Hi, is there any way to display an existing figure onto a GUI axes object?
Answers (2)
Walter Roberson
on 18 Jul 2012
1 vote
No. A figure can never be a child of anything other than the root object.
Also, an axes can never be the child of another axes.
It is possible to place images within axes, if that is what you are looking for. Just set() the image Parent property to be the target axes. You might also want to set the image XData and YData properties to move the image around within the axes.
8 Comments
Qingyang
on 18 Jul 2012
Walter Roberson
on 18 Jul 2012
No, a figure can never be a child of anything other than the root object. Also, subplots are actually axes, and axes cannot be children of other axes.
axes can overlap, if you are careful (and subplot() does not make this easy), but they can never contain other axes.
Image Analyst
on 18 Jul 2012
Qingyang, just make a figure (a GUI) and place your axes on the figure (GUI) and plot stuff or display images in the axes. What's wrong with doing it like that (the way everyone does it)?
Walter Roberson
on 18 Jul 2012
Qingyang is possibly using a previously-stored figure (complete with children). Possibly Qingyang wants to create a browser of such stored figures (a speculation on my part.)
Qingyang
on 19 Jul 2012
Walter Roberson
on 19 Jul 2012
Our guidance is going to depend upon the extent to which you just want to show something that looks like what is stored, compared to how much it has to act like what is stored. Figures have menu bars, callbacks, independent color maps, individual renderers, and so on. An image of a figure is much less effort to display than an actual figure.
Qingyang
on 19 Jul 2012
Image Analyst
on 19 Jul 2012
1 vote
To save a figure as an image to an image file, try the FAQ: http://matlab.wikia.com/wiki/FAQ#How_do_I_save_my_figure.2C_axes.2C_or_image.3F_I.27m_having_trouble_with_the_built_in_MATLAB_functions. which recommends using export_fig() - the most downloaded File Exchange file.
4 Comments
Qingyang
on 19 Jul 2012
Walter Roberson
on 19 Jul 2012
print() to the clipboard, import the clipboard. See the imclipboard() link I provided.
Alternately, display the figure and getframe() a copy of it.
Image Analyst
on 20 Jul 2012
Sorry - I guess I misinterpreted when you said "generate an image." Like Walter said, you can use getframe to get the contents of the figure into a variable in your program, but what are you're going to do with it? What's the point, when you already have the data that went into making up the figure? Why obtain that image if you're not planning on saving it out to disk?
Qingyang
on 20 Jul 2012
Categories
Find more on Creating, Deleting, and Querying Graphics Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!