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

188 次查看(过去 30 天)
I have a given figure which contains 2 subplots. the first subplot has a text on it. I want to change the text color and size using set/get parent/children commands... I already have the handle to the line in the top subplot(which is the first subplot as well). how can I do that? Is 'text' a parent or a child off the line in the top figure?

回答(1 个)

sixwwwwww
sixwwwwww 2013-12-7
编辑:sixwwwwww 2013-12-7
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 个评论
sixwwwwww
sixwwwwww 2013-12-7
编辑:sixwwwwww 2013-12-7
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:
ilona
ilona 2013-12-7
there is just a text in the middle of the 1st graph... its not a title or axis lable! and I only have the handle to the line in the top subplot so I need to find the handle for the text object(also located in the top subplot) and change it, this is my main problam actually... I don't now even if a text object is a child/parent... and how to access its handle
thank you for your help :)

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

产品

Community Treasure Hunt

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

Start Hunting!

Translated by