MATLAB Answers

Connecting different scatters with line

13 views (last 30 days)
Ivan Abraham
Ivan Abraham on 5 Mar 2017
Answered: Image Analyst on 5 Mar 2017
Let say I have the following:
hold on
How do I join the two different scatter plots with a line? The above example is bogus, but the idea is that I have two sets of scatter points that differ slightly in time, and I want to plot both of them on the same plots, and join the two by a line to see where each one moved.

Answers (1)

Image Analyst
Image Analyst on 5 Mar 2017
Try this:
% Define data. x is in row 1, y is in row2.
% Plot lines between corresponding pairs
for k = 1 : size(set1, 2)
plot([set1(1,k), set2(1,k)], [set1(2,k), set2(2,k)], ...
'rs-', 'LineWidth', 2, 'MarkerSize', 10);
hold on
grid on;


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by