How do I add refreshable text label to my plot?
Mostrar comentarios más antiguos
Hello,
After searching the web and the Q/A in your site I have decided to beat the experts. I am creating bar figure and I would like to see the value on top of each bar. My problem is that my figure refreshes every 2 seconds via timer (which is good), but the text on the bars is accumulating. I tried all values of 'erasemode' but it didn't help. I also tried to do h = text(...) and then delete h, but it didn't solve anything. Sorry to disturb if there is a similar question and solution.
Thanks in advance, Liad.
Respuesta aceptada
Más respuestas (2)
Fangjun Jiang
el 11 de Mayo de 2011
1 voto
set(h,'String','this is new text')
sco1
el 11 de Mayo de 2011
0 votos
The way your question reads, I'm assuming you are annotating the plot itself using the text() function?
Are you using hold?
5 comentarios
Liad
el 11 de Mayo de 2011
Laura Proctor
el 11 de Mayo de 2011
One thing that I see you are testing is if ht isempty. This probably isn't the way to test. Perhaps a test such as ishandle would be more appropriate. Because once you delete ht, it does still exist and will contain a number, it's just that it's no longer a handle object.
Fangjun Jiang
el 11 de Mayo de 2011
I don't understand. If you want to change the string of your text element and you have its handle, why can't you use
set(ht,'String',num2str(data(:,patlx)))
Liad
el 12 de Mayo de 2011
Fangjun Jiang
el 13 de Mayo de 2011
Once you created the text() element and get its handle ht(patlx), you can type get(ht(patlx)) in the Matlab command window to see all its properties. Then you can use set() to change most of the properties.
Start with the simplest option to create the text() element, step through to understand how it works and gradually add more options.
What do you mean "crashing"? Does it cause errors? or the figure does not show correctly? use the command drawnow() may help refreshing the figure.
Categorías
Más información sobre Annotations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!