Reputation: 696
I need to write a different number in each decade, in the bottom or top of my logarithmic plot.
I have these numbers in an array N
. There is a way to automate the process without write a for
loop for each decade?
In each decade there are 9 numbers, if I have two or three decades, how can write:
for i = 1:18
text(x(i), y, num2str(N(i)));
end
where, y
never change, N(i)
are my numbers, and x(i)
their position that I'm looking for.
I would like put in the orange box (or in the top) the number of black dots.
Upvotes: 0
Views: 94
Reputation: 7116
EDIT: I might have misunderstood your question. One interpretation is of using xticks
(explained below). The other is of placing text.
If all you wanted to do is place text at different locations, it's quite simple given that text
also accepts vectors.
x = 0:1:5;
y = x;
plot(x,y);
text(x+0.25,0.5*ones(6,1),{'One','Two','Three','Four','Five','Six'})
yields:
Unless you specifically want to position your labels, I would suggest that you use xticks.
For e.g.:
y = 0:1:5;
x = exp(-y.^2);
semilogx(x,y);
set(gca,'XTickLabel',{'One','Two','Three','Four','Five','Six'})
Gives:
Upvotes: 2