Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Put text into non-active Axes in MATLAB

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.

like image 505
Marc Avatar asked Sep 21 '10 13:09

Marc


1 Answers

Use the 'Parent' property in calling the text command

text(x,y,'text','Parent', Ax)
like image 128
Marc Avatar answered Oct 23 '22 03:10

Marc