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)
댓글 수: 0
채택된 답변
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
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.
추가 답변 (0개)
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!