MATLAB: Set uiaxes in matlab function as current figure to plot on

app designeraxeselegantMATLABplotset

Hi folks,
I had a question on how to plot on uiaxes from an m-file. This question got solved:
I wonder if there's a more elgant way to solve this problem by defining the axes at the beginning of the function and then continuously plot on it instead of defining the axes in every single plot command?! Something like:
Call of function:
myFunction(app.uiaxes)
Function:
function myFunction(uiAxes)
axes(uiAxes)
% plot 1
...
% plot 2
...
% plot x
It works fine the way it is right now, but what if I have an old function with lots of plot commands I want to include to a gui?

Best Answer

I would argue that it makes more sense (more elegant) to require specifying the parent axes to plot. The way that you want may cut down on some letters, but to me is less elegant and more prone to problems and confusion.
I would take the advice of the comment in the other answer: ctrl+F to update your old code.