Insert text in stacked plot points

19 vues (au cours des 30 derniers jours)
Rodolfo Villanueva
Rodolfo Villanueva le 1 Oct 2019
Modifié(e) : Adam Danz le 24 Nov 2020
I would like to insert text notes at certain values of a stacked plot type. I have tried the text function but I cant seem to get it to work.
Normally my stacked plots have a time variable (see screenshot). I would like to insert comments to certain dates and variables.
Thanks in advance!Capture.PNG

Réponses (1)

Adam Danz
Adam Danz le 19 Nov 2020
Modifié(e) : Adam Danz le 24 Nov 2020
stackedplot does not return the axis handles which is needed to place the text objects but you can get the axis handles using the undocumented NodeChildren property. Use flipud to reverse the order of axis handles so they appear in the same order as the stack.
S = stackedplot(rand(50,4));
ax = flipud(findobj(S.NodeChildren, 'Type','Axes'));
text(ax(1),10,.8, 'Text1')
text(ax(2),20,.6, 'Text2')
text(ax(3),30,.4, 'Text3')
text(ax(4),40,.2, 'Text4')

Catégories

En savoir plus sur Graphics Object Programming dans Help Center et File Exchange

Produits


Version

R2019a

Community Treasure Hunt

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

Start Hunting!

Translated by