How to label a stem plot??

62 ビュー (過去 30 日間)
Milosha Britto Nordbø
Milosha Britto Nordbø 2020 年 5 月 3 日
コメント済み: Star Strider 2020 年 5 月 16 日
How can i add labels to the stem diagram?? I have attached a pic to be specific where i require the labels.

採用された回答

Star Strider
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 件のコメント
Milosha Britto Nordbø
Milosha Britto Nordbø 2020 年 5 月 16 日
Thank you. I made one change and it worked (see below the change in bold).
lblc = sprintfc('%d',Group1);
Thank you once again.
Star Strider
Star Strider 2020 年 5 月 16 日
As always, my pleasure!
I somehow missed the ‘1’. My apologies!

サインインしてコメントする。

その他の回答 (1 件)

Milosha Britto Nordbø
Milosha Britto Nordbø 2020 年 5 月 16 日
No problem, at least I understood it. If you had the '1' then I wold never understand the logic behind it.
  1 件のコメント
Star Strider
Star Strider 2020 年 5 月 16 日
Noted!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeGrid Lines, Tick Values, and Labels についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by