How to set an uneven distribution of xticks?

23 views (last 30 days)
Hi All,
I have this:
plot([1.244812244389030e+02;1.387135810473820e+02;1.494424738154610e+02;1.508949276807980e+02;1.512359276807980e+02;1.131822169576060e+02;98.110316708229500;87.436364089775600]);
set(gca,...
'xtick',[1, 1.15, 1.3, 1.45, 1.75, 1.95, 2.45, 2.95],...
'xticklabel',{'1' '1.15' '1.3' '1.45' '1.75' '1.95' '2.45' '2.95'});
When plotting the xticks do not fit the actual data points which should be unevenly distributed along the xaxis. Can somebody help?
Many Thanks!!
Mike

Accepted Answer

Star Strider
Star Strider on 3 Mar 2015
Edited: Star Strider on 3 Mar 2015
When I ran your code, the 'XTick' locations were correct. You didn’t supply an x-vector, so MATLAB supplied a default x-vector, that went from 1 to 8, and the 'XTick' values were plotted with respect to that. What x coordinates did you intend to use? Provide them to plot, and the 'XTick' values will plot where you want them to be on the x-axis.
Guessing here but if you wanted your x-vector to be the vector you provided to 'XTick', you get the plot that I believe you want:
plot([1, 1.15, 1.3, 1.45, 1.75, 1.95, 2.45, 2.95], [1.244812244389030e+02;1.387135810473820e+02;1.494424738154610e+02;1.508949276807980e+02;1.512359276807980e+02;1.131822169576060e+02;98.110316708229500;87.436364089775600]);
set(gca, 'xtick',[1, 1.15, 1.3, 1.45, 1.75, 1.95, 2.45, 2.95], 'xticklabel',{'1' '1.15' '1.3' '1.45' '1.75' '1.95' '2.45' '2.95'});
Other than not providing an x-vector to plot, you did everything correctly.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!