Using the set
command you can specify the xTick
and xTickLabel
(near the bottom of the link) properties of the axis separately, xTick defines the tick marks locations and xTickLabel defines the labels.
So after plotting the data:
plot(x_values,y_values);
we can freely set the locations, in this example they are spaced evenly between zero and the max of x_values
. The set
command is then be used to set the axis properties, (gca
is the current axis handle)
x_label_locations = linspace(0,max(x_values),numel(x_labels));
set(gca,'xTick',x_label_locations,'xTickLabel',x_labels)