MATLAB: How to use text as tick marks in x-axis in a plot

plotscatter

I am generating a graph where I want to specify some tick on x-axis with text. Please find attached the figure of what I want to do.

Best Answer

Here is one way:
% Some pretend data
N = 10;
x = sort(2*rand(N,1));
y = sort(2*rand(N,1));
% Plot the figure
figure
plot(x,y)
% Define the tick locations, and label them
set(gca,'XTick',0.5:0.5:2)
set(gca,'XTickLabel',{'\beta=0.5','\beta=1.0','\beta=1.5','\beta=2.0'})
That is pretty manual. If you need it to be more automatic, you'll need to get the values of the x-ticks, and then use that vector of values to create the labels.