Draw line between two points if x distance is longer than...
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Katerina Kunorzova
le 15 Mar 2021
Commenté : Katerina Kunorzova
le 15 Mar 2021
I have scatter plot. I need draw line or something similar between two point if their x distance is longer than 2. I draw to picture.
Thank You!
0 commentaires
Réponse acceptée
Rik
le 15 Mar 2021
You can easily find the indices of such locations (assuming x and y are sorted along x):
x=[linspace(-16,-8,200) linspace(-5.5,2,200)];
y=rand(size(x));
ind=find(diff(x)>=2);
plot(x,y,'.b'),hold on
for n=1:numel(ind)
plot(x(ind(n)+[0 1]),y(ind(n)+[0 1]),'b');
end
hold off
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Scatter Plots dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!