2

Following up on this lovely answer https://stackoverflow.com/a/45442483/2798895 how to draw a line between two sets of points I need to have an arrow (--->) between the corresponding points. Is there a way of doint it?

I found some examples of using quiver but they don't connect from (x,y) to (u,v). They are adding only a short arrow to (x,y) that is pointing in the direction of (u,v) but not touching it.

My line plot (from the above mentioned answer):

set1 = [1,2; 3,4; 5,6];
set2 = [10,20; 30,40; 50,60];
figure; 
plot(set1(:,1),set1(:,2),'b+',set2(:,1),set2(:,2),'g+')
hold on
x = [set1(:,1) set2(:,1)].';
y = [set1(:,2) set2(:,2)].';
plot(x,y,'r')
hold off
drawnow 

My quiver plot:

set1 = [1,2; 3,4; 5,6];
set2 = [10,20; 30,40; 50,60];
figure; 
plot(set1(:,1),set1(:,2),'b+',set2(:,1),set2(:,2),'g+')
hold on
quiver(set1(:,1),set1(:,2),set2(:,1),set2(:,2));
hold off
drawnow 

How would that be possible to connect the points with an arrow e.g. like quiver but with longer arrows?

flor1an
  • 810
  • 12
  • 26
  • I came across this post regarding arrow drawing, with a quiver hack, [here](https://stackoverflow.com/questions/25729784/how-to-draw-an-arrow-in-matlab) – informaton Aug 08 '17 at 19:58
  • You can also look [here (2nd part)](https://stackoverflow.com/questions/44161501/matlab-scatter-with-tooltip-showing-other-kinds-of-data-and-connecting-points-wi/44175176#44175176) for an example using `annotation` – EBH Aug 09 '17 at 09:43
  • 1
    For `quiver`, try this: `quiver(set1(:,1),set1(:,2),set2(:,1)-set1(:,1),set2(:,2)-set1(:,2),'AutoScale','off');` – EBH Aug 09 '17 at 10:05

0 Answers0