I have a plot which is having some points. How to join those points
1 view (last 30 days)
Show older comments
I have a plot which is having some points. How to join those points
2 Comments
Image Analyst
on 20 Feb 2016
How did you put those points on the graph in the first place. The Mind Reading Toolbox has not been released yet so we'd need to see your code.
Walter Roberson
on 20 Feb 2016
How they were put on the graph in the first place does not matter overly: it is possible to search all the different kinds of graphics primitives looking for the points. You do not need the Mind Reading Toolbox until you try to decide what order to connect them in.
Answers (1)
Walter Roberson
on 19 Feb 2016
That gets a bit involved if you are using R2014a or earlier and using scatter() (but certainly can be done). It gets notably messier to work out if you are using patch() to draw the points, or one of the routines that invokes patch such as some of the contour variants. If you are using a surface or mesh plot in which some of the points are black (or more properly, the same color as the background they are plotted on) then you could get into arguments about whether those visually-hidden points should be drawn or not.
There are ways it can be done. But really the way it should be done is to keep track of the points at the time you would normally plot them, and plot the joining line once you know them all. For example, instead of
for K = 1 : 20
%generate one point
x = K.^2;
y = sin(x);
%plot the one point
plot(x, y);
hold on
end
You would use
%generate all of the points
for K = 1 : 20
x(K) = K.^2;
y(K) = sin(x(K));
end
%plot all of the points
plot(x, y);
0 Comments
See Also
Categories
Find more on Discrete Data Plots in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!