x axis label issue...

1 Ansicht (letzte 30 Tage)
Chris E.
Chris E. am 31 Jul. 2013
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!

Akzeptierte Antwort

the cyclist
the cyclist am 31 Jul. 2013
Bearbeitet: the cyclist am 31 Jul. 2013
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 Kommentar
Chris E.
Chris E. am 31 Jul. 2013
XTick, Yet that did it! Thanks!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by