How to retrieve previousely created figures into a GUI
Show older comments
Hello,
I know this has been a bit covered many times (I've had long searches and tests before posting this), but I cannot make this work. Basically I have a function activated by a pushbutton inside a GUI with nested loops, and inside these loops some figures are created automatically.
Once the function has ended I would like to use a popup menu to select which of these figures I would like to plot on an axes.
I've tried to save these figures to image files, and then just show these images on the axes object, but it doesn't work well because the figures have different sizes and proportions. So I've tried to work with .FIG files so it would resize things more or less automatically inside the figure to fit the available space, but no success.
How can I get around this problem?
Thanks!
EDIT: I not only need the data, but also the legends, axis labels, etc.
Answers (2)
Walter Roberson
on 1 Mar 2016
0 votes
6 Comments
Walter Roberson
on 1 Mar 2016
There is no way you can put a legend or colorbar inside an axes for R2014a or earlier. I am not certain about whether it can be done for R2014b or later. In R2014a or earlier, legend and colorbar are themselves axes.
I would suggest to you that you probably do not need to plot in a particular axes: that what you need to do is designate a particular area of the figure to put the contents in. The way to do that is to create a uipanel. You can then copyobj the contents of the figure into the uipanel. (Watch out for the colormap and Renderer: if you are using R2014a or earlier, those are figure properties.) uipanel can contain axes and hggroup and even other uipanel, and all positions and sizes in 'normal' units will use the size of the uipanel as their base.
Matt
on 1 Mar 2016
Walter Roberson
on 2 Mar 2016
Right. All except for uimenu and uitoolbar, as those cannot be placed inside uipanel .
Matt
on 7 Mar 2016
Walter Roberson
on 7 Mar 2016
That's what the findall() is about, peeking into the figure to retrieve the objects that can be productively copied.
Jan
on 1 Mar 2016
0 votes
Note that data, axes labels and legends belong to the axes, not to the figure.
You cannot copy the contents of a figure to an axes object. What about keeping the figure as a figure in an own window? This would be rather direct and easy. The demand for saving a figure as an image file and have the ability to resize it dynamically is a contradiction. I think there will be a much easier approach.
You could use FEX: WindowAPI to create a borderless window and set its position automatically, such that it looks like it is embedded in the original figure. But I'd hesitate to implement such fancy tricks, because moving the original window will update the position of the embedded window with a certain delay only and this will cause optical illness. It is simply to ugly to be nice.
Categories
Find more on Interactive Control and Callbacks 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!