x axis label issue...

3 ビュー (過去 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 Center および File ExchangeAxis Labels についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by