필터 지우기
필터 지우기

Plot graph with different labels

조회 수: 1 (최근 30일)
Edward
Edward 2013년 9월 27일
댓글: Edward 2013년 9월 27일
Hi,
I have a data set
y = [10,15,23];
x = {'jan','feb','mar'};
but obviously you cant plot Strings so i made a third array:
z=[1,2,3];
to represent the Strings. I would like to plot(z,y) but with x as the labels on the x axis (i dont want to see the numbers 1,2,3), how is this possible?
Also if I had 100 data points, how would i make it so only a few of the labels will be shown? thanks

채택된 답변

Azzi Abdelmalek
Azzi Abdelmalek 2013년 9월 27일
편집: Azzi Abdelmalek 2013년 9월 27일
y = [10,15,23];
x = {'jan','feb','mar'};
z=[1,2,3];
plot(z,y)
set(gca,'xtick',z,'xticklabel',x)
  댓글 수: 3
Azzi Abdelmalek
Azzi Abdelmalek 2013년 9월 27일
편집: Azzi Abdelmalek 2013년 9월 27일
Look at this example
y= [10,15,23 14 5 2 7 45 2];
x = {'jan','feb','mar' 'avr' 'mai' 'jun' 'jui' 'aou' 'sep' };
z=1:numel(y)
plot(z,y)
idxi=round(linspace(1,numel(z),5))
set(gca,'xtick',z(idxi),'xticklabel',x(idxi))
Edward
Edward 2013년 9월 27일
Perfect! I dont suppose theres anyway to make this update with zooming in on the plot too?

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

추가 답변 (0개)

카테고리

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

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by