I have a plot which is having some points. How to join those points

1 次查看(过去 30 天)
I have a plot which is having some points. How to join those points
  2 个评论
Image Analyst
Image Analyst 2016-2-20
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
Walter Roberson 2016-2-20
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.

请先登录,再进行评论。

回答(1 个)

Walter Roberson
Walter Roberson 2016-2-19
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);

类别

Help CenterFile Exchange 中查找有关 Discrete Data Plots 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by