How can I update plot title using set function?

13 ビュー (過去 30 日間)
Myung Hyun Jo
Myung Hyun Jo 2021 年 8 月 8 日
コメント済み: Myung Hyun Jo 2021 年 8 月 8 日
I want to update the title of plot in a loop using 'set' fucntion, but I could not find the property for "Title".
Can I update title using 'set'? Or, how can I update the title of plot?
Previously, I just re-draw plots in a loop, but the figure update gets slower.
So, I was trying to use 'set' to update the data and title only.
A brief version of my script is like below. It makes error: "Unrecognized property Title for class Line."
I tried to use 'title', but it updates title of another figure.
Thank you for reading this.
figure('Name','Window Title','NumberTitle','off');
hTracePlot = plot(1:10, zeros(1,10), '-o');
title('old title')
i = 0;
while i < 5
figure('Name','dummy window') %this figure is for another data.
set(hTracePlot,'XData',1:10,'YData',i*(1:10))
set(hTracePlot, 'Title', 'new title')
%title(['new title ' num2str(i)])
i = i+1;
keyanswer =input('enter to proceed : ','s');
end

採用された回答

Simon Chan
Simon Chan 2021 年 8 月 8 日
You may modify your code based on the following if this is what you want.
i = 0;
while i < 5
subplot(2,3,i+1)
plot(1:10, i*(1:10), '-o');
t = get(gca,'Title');
set(t,'String',strcat('Figure for i = ', num2str(i)));
grid on;
i = i+1;
end
  1 件のコメント
Myung Hyun Jo
Myung Hyun Jo 2021 年 8 月 8 日
Thank you! It worked.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeTitle についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by