how to name xbars with the names on number sequence?

3 次查看(过去 30 天)
If I have 10 bars on a bar graph, how could i name each bar with a sequence number, for example to use
names=[1:1:10]
set(gca,'xticklabel',names)

采纳的回答

Star Strider
Star Strider 2018-1-26
That looks as though it should work. If it is not working, add 'XTick' to specify the locations where the labels should appear:
names = [1:1:10];
set(gca, 'XTick',names, 'xticklabel',names)
  3 个评论
Star Strider
Star Strider 2018-1-26
This works:
b= b/25201*100;
d=d*100;
figure
hBar = bar(1:numel(b), [d b], 'stack')
grid on
axis([0 (numel(b)+1) 0 100])
names = [5:5:95];
getbar = get(hBar);
set(gca, 'XTick',getbar(1).XData, 'XTickLabel',names)
NOTE It is necessary to return ‘hBar’, the handle of the bar plot, so be sure to add that.
Philippe Corner
Philippe Corner 2018-2-18
Mr star Strider, could you check this question out please? https://la.mathworks.com/matlabcentral/answers/383371-how-to-make-all-the-legend-appear-in-a-plot

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 MATLAB 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by