MATLAB: Change x axis, i have a plot of data from a headset. then i have 5 lines from a game, so i want 0-time from start(green) line till the end(red line), is it possible

plotxaxis

plot(data(2:end,3),data(2:end,1));
hold on;
plot(data(2:end,3),data(2:end,2), 'k');
plot([Start Start],[0 1], 'g');
plot([mistake1 mistake1],[0 1], 'c');
plot([mistake2 mistake2],[0 1], 'c');
plot([mistake3 mistake3],[0 1], 'c');
plot([mistake4 mistake4],[0 1], 'c');
plot([End End],[0 1], 'r');

Best Answer

Not sure what your asking for.
Do you need to re-define the limits of your x-axis so that they go from the green to the red line? That would be
xlim([start end]);
Or maybe you want that your scale be 0 at the green line... In that case you simply substract start from all the xdata in your plots. When plotting
plot(data(2:end,3)-start,data(2:end,1));
and likewise for the others.
Otherwise, with focus on the axes containing your plots, like the figure you sent,
% get the handles for the lines
h = findobj(gca,'type','line','linestyle','-');
% loop over the handles
for j = 1:length(h)
% translate the xdata
set(h(j),'xdata',get(h(j),'xdata')-start);
end