Reputation: 7131
I have 3 arrays,
y = [1,4,6,8,2,5,......];
x = [1,2,3,4,5,6,......];
xlabel = {'label1','label2','label3',........};
where each element in xlabel is the label for each element of the x array.
I am plotting this using:
plot(x,y);
set(gca,'xtick',x,'xticklabel',xlabel);
But because my arrays hold thousands of elements I am getting a black bar as a label because MATLAB is printing every label (see image).
How do I change this so MATLAB only prints a select few of my xlabels?
Upvotes: 1
Views: 2757
Reputation: 112659
You can do for example:
selected = 1:100:numel(x); % change the "100" as desired
set(gca,'xtick',x(selected),'xticklabel',xlabel(selected));
Upvotes: 1