필터 지우기
필터 지우기

How to add more names on a plot axis

조회 수: 1 (최근 30일)
Siskia Yarzagaray
Siskia Yarzagaray 2016년 5월 15일
댓글: Siskia Yarzagaray 2016년 5월 16일
As shown in the graph below, I have edited to X-axis to include names. At the moment it only shows 6 names. How do I increase the number of names that may be shown on the X-axis? To be a bit more specific, each bar should show its own name underneath it.
I've made use of the folowing code in order to edit the axis.
%
ax = gca;
set(ax, 'XTickLabel', y, 'XMinorTick','on'); %Change the YtickLabels to course code.
ax.XTickLabelRotation = 90;

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2016년 5월 15일
편집: Azzi Abdelmalek 2016년 5월 15일
Look at this example
x=1:20
y=randi(10,1,numel(x))
bar(x,y)
n=numel(y)
names=strsplit(sprintf('name%d ',1:n))
ax = gca;
ax.XTick=x
set(ax, 'XTickLabel', names, 'XMinorTick','on');
ax.XTickLabelRotation = 90;
  댓글 수: 1
Siskia Yarzagaray
Siskia Yarzagaray 2016년 5월 16일
Works perfectly. Thank you very much :D

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Labels and Annotations에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by