66 views (last 30 days)

Hello,

I am looking to show how oxygen and carbon covary over time in a simple x-y scatterplot. However, instead of the points being connected by lines, I'd like them to be connected by arrows. Is it possible to do this on MatLab or would I need to export the figure and insert the arrows using Adobe?

Here is an example of a plot code:

% Inflata

figure('Color','w');

plot(c13xi87,o18xi87);

ylabel('G. Inflata \delta^1^8O');

set(gca,'YDir','reverse');

xlabel('G. Inflata \delta^1^3C');

aborghes
on 7 Aug 2017

Edited: Walter Roberson
on 8 Jun 2020

Hi Vince, I would recommend using the quiver() function. The doc for it is located here: https://mathworks.com/help/releases/R2017a/matlab/ref/quiver.html

You can do something like the following code, assuming both data-sets are 1-D matrices

for i=1:length(c13xi87) - 1

p1 = [c13xi87(i) o18xi87(i)];

p2 = [c13xi87(i+1) o18xi87(i+1)];

dp = p2 - p1;

quiver(p1(1),p1(2),dp(1),dp(2),0);

hold on

end

hold off

Walter Roberson
on 7 Aug 2017

Walter Roberson
on 9 Aug 2017

Or possibly it would make sense to use stream2() or stream3() in connection with streamlines()

José-Luis
on 8 Aug 2017

Edited: José-Luis
on 8 Aug 2017

x = rand(10,1);

y = rand(10,1);

dx = diff(x);

dy = diff(y)

plot(x,y,'ro');

hold on

quiver(x(1:end-1),y(1:end-1),dx,dy,0)

Farshid Tazesh
on 5 Jun 2020

Hi Jose. I used your code. Very helpfull. Thank you so much for sharing.

- Farshid

Opportunities for recent engineering grads.

Apply Today
## 5 Comments

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/351862-is-it-possible-to-connect-points-on-a-scatter-plot-with-arrows-instead-of-a-line#comment_475186

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/351862-is-it-possible-to-connect-points-on-a-scatter-plot-with-arrows-instead-of-a-line#comment_475186

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/351862-is-it-possible-to-connect-points-on-a-scatter-plot-with-arrows-instead-of-a-line#comment_475411

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/351862-is-it-possible-to-connect-points-on-a-scatter-plot-with-arrows-instead-of-a-line#comment_475411

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/351862-is-it-possible-to-connect-points-on-a-scatter-plot-with-arrows-instead-of-a-line#comment_475415

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/351862-is-it-possible-to-connect-points-on-a-scatter-plot-with-arrows-instead-of-a-line#comment_475415

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/351862-is-it-possible-to-connect-points-on-a-scatter-plot-with-arrows-instead-of-a-line#comment_475426

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/351862-is-it-possible-to-connect-points-on-a-scatter-plot-with-arrows-instead-of-a-line#comment_475426

## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/351862-is-it-possible-to-connect-points-on-a-scatter-plot-with-arrows-instead-of-a-line#comment_475587

⋮## Direct link to this comment

https://ww2.mathworks.cn/matlabcentral/answers/351862-is-it-possible-to-connect-points-on-a-scatter-plot-with-arrows-instead-of-a-line#comment_475587

Sign in to comment.