Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bring text to the front of a plot

I have a figure in MATLAB. Then I add a text to it by typing,

b = text(0.5, 0.5, 'Detector action', 'Rotation', -70, 'FontSize', 25);

But the text goes behind the figure (See below), enter image description here

I also tried,

uistack(b, 'top');

but it didn't work.

like image 691
Mohammad Avatar asked Dec 20 '18 17:12

Mohammad


1 Answers

The easiest way is not to bother with a text at all, but instead use an annotation, since such an object will be (at least by default) above the axes (and thus, anything plotted inside them).

The trick with annotation objects, is that counter-intuitively, we need not use a TextBox, but instead a TextArrow, while making the arrow itself invisible.

For example:

figure(); membrane(); 
annotation('TextArrow', [.5 .5], [.5 .5], 'String','Some text', 'TextRotation', -30, ...
           'HeadStyle','none','TextBackgroundColor','w' );

enter image description here

like image 90
Dev-iL Avatar answered Oct 19 '22 20:10

Dev-iL