
How can I update plot title using set function?
16 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Myung Hyun Jo
le 8 Août 2021
Commenté : Myung Hyun Jo
le 8 Août 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 commentaires
Réponse acceptée
Simon Chan
le 8 Août 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

Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Title dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!