How to label a stem plot??
조회 수: 62 (최근 30일)
이전 댓글 표시
How can i add labels to the stem diagram?? I have attached a pic to be specific where i require the labels.
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/289961/image.png)
댓글 수: 0
채택된 답변
Star Strider
2020년 5월 3일
Try this:
Year = 1995:2020;
Group = randi([2000 11000], size(Year));
figure
stem(Year, Group, 'filled')
lblc = sprintfc('%d',Group);
text(Year, Group+100, lblc, 'HorizontalAlignment','center', 'VerticalAlignment','bottom')
Make appropriate changes to the text and sprintfc calls to display the result you want. (The sprintfc function is undocumented, however uses the sprintf syntax. You can also use the compose function to produce a cell array of labels.)
댓글 수: 2
추가 답변 (1개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!