I can create a new axes on the current figure:
ax = gca;
% or
ax = axes;
If I already have a handle to the figure I want to work with, I can set that figure as current and then create the axes:
figure(h);
ax = axes;
But as far as I can figure out there's no way to create an axes on an arbitrary figure, without bringing it to the foreground (and having it steal focus from other windows)?
Yes, there is:
ax = axes('Parent',h)
where h
is a handle to the figure.
This makes use of the syntax (see documentation)
axes('PropertyName',propertyvalue,...)
: creates an axes object having the specified property values
to set the 'Parent'
property of the created axes. That way the axes are created in that figure, without bringing it to focus.