Labeling a stacked bar
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Milosha Britto Nordbø
il 23 Mag 2020
Risposto: Srivardhan Gadila
il 28 Mag 2020
I am trying to lable a stacked bar. Somehow I am unable to get it. Given below are my codes. I tried the below two options but it did not work.
The error i get is 'Error using text. Value must be a column or row vector.'
Option one:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/298578/image.png)
Option 2:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/298583/image.png)
0 Commenti
Risposta accettata
Srivardhan Gadila
il 28 Mag 2020
The following example might help you:
x = [1 2 3];
vals = [2 3 6; 11 23 26];
b = bar(x,vals);
xtips1 = b(1).XEndPoints;
ytips1 = b(1).YEndPoints;
labels1 = string(b(1).YData);
text(xtips1,ytips1,labels1,'HorizontalAlignment','center',...
'VerticalAlignment','bottom')
xtips2 = b(2).XEndPoints;
ytips2 = b(2).YEndPoints;
labels2 = string(b(2).YData);
text(xtips2,ytips2,labels2,'HorizontalAlignment','center',...
'VerticalAlignment','bottom')
0 Commenti
Più risposte (0)
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!