# How do I change color of a text in a given subplot?

225 views (last 30 days)

Show older comments

### Answers (1)

sixwwwwww
on 7 Dec 2013

Edited: sixwwwwww
on 7 Dec 2013

you can change text color as follow:

x = -pi:.1:pi;

y = sin(x);

plot(x,y)

text(-pi/4, sin(-pi/4), '\leftarrow sin(-\pi\div4)', 'HorizontalAlignment','left', 'Color', 'r')

Or if you wanted to use set command then you can do it as follow:

h = text(-pi/4, sin(-pi/4), '\leftarrow sin(-\pi\div4)', 'HorizontalAlignment','left');

set(h, 'Color',[1, 0 ,0])

##### 3 Comments

sixwwwwww
on 7 Dec 2013

Edited: sixwwwwww
on 7 Dec 2013

Iy you already have handler 'h' for object whose color and font property you want to set then use:

set(h, 'Color',[1, 0 ,0], 'FontSize', 20)

Which text you want to change in that figure? Is it title or xlabel or ylabel?

Also in order to find some specific object in figure you can use 'findobj'. See for more information:

### See Also

### Categories

### Products

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!