I have a barplot where the bars are located at the following x-coordinates:
1,2,3,4,5,6,7,8,9,10,12,14,16,18,20,22,24,26,28,30,35,40,45,50,55,60,70,80,90
I want to show these values at the XTickLabel
, however when I use
figure(1);
Vector = [1 2 3 4 5 6 7 8 9 10 12 14 16 18 20 22 24 26 28 30 35 40 45 50 60 70 80 90]
bar(Vector,Vector);
xticklabels(Vector);
I get the following output, but I want that my XTickLabel
to look like Vector
at the corresponding values:
As you can see the XTickLabel
only goes to 12 and some bars are not labeled.
I tried to use
set(gca,'Xtick',1:1:Vector(length(Vector)))
But this uses a linear interval for the Xtick
.
As Adiel had mentioned, use:
set(gca,'Xtick', Vector);
You don't need xticklabel
, unless you want ticks label texts that are different from the values at their positions.