views:

24

answers:

1

Most MATLAB plotting commands allow you to specify which axes to act on, for instance

plot (x,y) 

plots in the current axes, but

plot(Ax, x, y) 

will plot in the axes Ax.

Similarly, you can label the x- or y- axis of a non-active axes

xlabel(Ax, 'this label goes on the x-axis of Ax whether or not Ax == gca')

But the text command doesn't appear to support this feature. Is there a way to put text into a non-active axes?

I ask because this sequence:

currentAxes = gca;
axes(Ax); %MLINT warning here
text(x,y,'this text ends up on axes Ax now');
axes(currentAxes); %MLINT warning here

will throw MLINT warnings that calling axes(axes_handle) is slow in scripted functions.

+4  A: 

Use the 'Parent' property in calling the text command

text(x,y,'text','Parent', Ax)
Marc
this also works for patch, which has a similar syntax
Marc