Append/Alter string in Title
8 次查看(过去 30 天)
显示 更早的评论
I would like to append additional text to the title of a plot. How do I "get" the title string in order to append the added text and replace the title with the modified string?
The help tells me how to replace the title, but I want to add, say, a date, or filename.
0 个评论
采纳的回答
Wayne King
2012-5-2
plot(randn(100,1));
h = title('Test');
origtitle = get(h,'String');
set(h,'String',[origtitle ' 2'])
3 个评论
Daniel Shub
2012-5-3
The terminology matters here: Figure->Axis->Object. The gca function returns the handle to the current Axis, not the Figure. The plot handle (presumably the handle returned by plot), is a handle to an Object.
The axis object has a child object called Title. You can get this with h = get(gca, 'Title'). The h from this command will be identical to the h in Wayne's answer.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Title 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!