x axis label issue...

조회 수: 1 (최근 30일)
Chris E.
Chris E. 2013년 7월 31일
Hello All,
Well I'm not sure how to change the x label at specific points. The code below generates a similar structure to what I'm using, I need the labels to be placed under each line on the x axis. So the variable, "xlabelIWant" shows the position of the line on the x axis and then I would like to label them with numbers increasing from one. So the first line that goes up from the x axis is labeled as 1, the second line going up is labeled as 2 and so on. I know how to rename the x axis label, but not how to rename it at specific points. I'm sure it is some propriety, but I may not know of it. Any help anyone offers will be greatly appreciated. Thank you! Here is the code below...
k = 0;
amt = 10;
for n = 1:amt
y=1:100;
sigma=round(rand*5+10);
mu=round(rand*10+40);
A=round(rand*4+2);
x=A*exp(-(y-mu).^2/(2*sigma^2))+rand(size(y))*0.3;
k(n,:) = max(x);
t(n,:) = x;
end
m = repmat(cumsum([0 k(1:end-1)'])',1,size(t,2));
t = t+m;
%all of above it to generate fake data..
plot(t,1:length(t),'b')
xlabelIWant = [t(:,1) (1:amt)'];
set(gca,'XTickLabel',{1, 2, 3, 4, 5, 6, 7, 8, 9, 10})
%where 1 is found at t(1,1) and 2 is found at t(2,1) and so on
Thanks again!

채택된 답변

the cyclist
the cyclist 2013년 7월 31일
편집: the cyclist 2013년 7월 31일
figure
plot([1 2 3 4],[5 6 7 12])
set(gca,'XTick',[1 2 3]); % Set positions
set(gca,'XTickLabel',{'what','you','want?'}) % Set labels
  댓글 수: 1
Chris E.
Chris E. 2013년 7월 31일
XTick, Yet that did it! Thanks!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Descriptive Statistics에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by