Display values as labels at the tips of serie of bars.

8 ビュー (過去 30 日間)
Haythem Zouabi
Haythem Zouabi 2019 年 9 月 30 日
編集済み: Adam Danz 2019 年 10 月 2 日
In Matalb R2019b, to display values as labels at the tips of serie of bars, we can use :
xtips1 = b(1).YEndPoints + 0.3;
ytips1 = b(1).XEndPoints;
labels1 = string(b(1).YData);
text(xtips1,ytips1,labels1,'VerticalAlignment','middle')
These commands do not work in Matlab R2018b. Do you have solution for this problem.
Thanks,

採用された回答

Star Strider
Star Strider 2019 年 9 月 30 日

その他の回答 (1 件)

Adam Danz
Adam Danz 2019 年 9 月 30 日
編集済み: Adam Danz 2019 年 10 月 2 日
You've got your x's and y's mixed up.
xtips1 = b(1).YEndPoints + 0.3;
% ^ should be XEndpoints
ytips1 = b(1).XEndPoints;
% ^ YEndpoints
labels1 = string(b(1).YData);
text(xtips1,ytips1,labels1,'VerticalAlignment','middle')
But more simply, and to center the text on top of the bars (unless they are grouped),
text(b.XData,b.YData,labels1,'VerticalAlignment','bottom','HorizontalAlignment','center')
191002 094435-Figure 1.png

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by