MATLAB: Plotting Matrix points: 2

guideplotting

Given a matrix:
B
ans =
30.7805 28.7527 25.7110 23.6832 19.6268 17.5949 14.5547 11.5147 8.4725 5.4313
29.7667 27.7333 24.6923 21.6549 18.6114 15.5708 12.5285 9.4806 7.4582 4.4159
B.'
ans =
30.7805 29.7667
28.7527 27.7333
25.7110 24.6923
23.6832 21.6549
19.6268 18.6114
17.5949 15.5708
14.5547 12.5285
11.5147 9.4806
8.4725 7.4582
5.4313 4.4159
I am trying to plot the data as shown in this image:
I am trying to plot the 1st column as the orange points and the 2nd column as the blue points. The time between the points form a small box. The only axes I'm interested in is the X which will be composed of the overall time of the video. I am attempting to do this in a GUIDE axes. Eventually I want the user to be able to select the points and add labels.
Any advice in accomplishing this will be greatly appreciated!

Best Answer

a =[30.7805 29.7667
28.7527 27.7333
25.7110 24.6923
23.6832 21.6549
19.6268 18.6114
17.5949 15.5708
14.5547 12.5285
11.5147 9.4806
8.4725 7.4582
5.4313 4.4159]
axis([0,max(a(:))+max(a(:))/5,0,2])
hold on
plot(a(:,1),1,'pb')
plot(a(:,2),1,'pr')
h=0.02;y=1;
arrayfun(@(n)rectangle('EdgeColor','y','Position',...
[min([a(n,1) a(n,2)]),y-h,abs(a(n,1)-a(n,2)),2*h]),1:size(a,1))
%with numbers if you want them:
arrayfun(@(n)text(min([a(n,1) a(n,2)]),y+2*h,...
num2str(size(a,1)-n+1)),1:size(a,1))