필터 지우기
필터 지우기

how to add numbers above the tips of a bar chart

조회 수: 5 (최근 30일)
Tariq Hammoudeh
Tariq Hammoudeh 2022년 1월 9일
댓글: Rik 2022년 1월 10일
I have an array
b=[ 1 2 3]
then i use bar(b)
now how can i write the value of each bar (so the elements of the array) over each bar.

채택된 답변

Rik
Rik 2022년 1월 9일
b=[1 2 3];
labels=arrayfun(@num2str,b,'Uni',0);
bar(b)
text(1:numel(b),b+0.1,labels)
  댓글 수: 4
Tariq Hammoudeh
Tariq Hammoudeh 2022년 1월 9일
@Walter Roberson Thank you for that.
Just one more question, im using:
xticks(1:3);
xticklabels({'one', 'two' , 'three'})
How can i increase the font size, because
FontSize
doesnt work in xticklabels
Rik
Rik 2022년 1월 10일
The documentation of the axes properties states the following:
The font size affects the title, axis labels, and tick labels.
So to adjust the tick label font you will have to change the axes font size.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Line Plots에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by