How can I update plot title using set function?

조회 수: 14 (최근 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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Title에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by