I have a function which plot a certain graph. How should I code this so that the function will not deliberately plot in a figure but in the axes of the gui instead?

 Accepted Answer

You need to tell that plotting command which axes to use, by providing the axes handle. How to do this depends on the plotting command that you are using (you did not state this in your question), but as an example plot accepts the axes handles as the first input argument (here fgh is the figure/tab/panel handle):
axh = axes(fgh,...)
plot(axh,...)
For some other functions you will need to set the 'parent' property, read their help pages and property pages to know the required syntax:
somefun(...,'Parent',axh)
If you want to write reliable code than always obtain and use explicit graphics handles for all graphics functions and operations. Never assume that the current figure/axes/line/patch/... are the ones that you code needs to access. Read more here:

More Answers (0)

Categories

Find more on Graphics Object Properties in Help Center and File Exchange

Tags

Asked:

on 3 Apr 2018

Edited:

on 3 Apr 2018

Community Treasure Hunt

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

Start Hunting!