Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

Bring text to the front of a plot

Writer Sebastian Wright

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.

10

1 Answer

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

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy