
How can I update plot title using set function?
15 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Myung Hyun Jo
am 8 Aug. 2021
Kommentiert: Myung Hyun Jo
am 8 Aug. 2021
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
0 Kommentare
Akzeptierte Antwort
Simon Chan
am 8 Aug. 2021
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

Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Title finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!