title: Extracting clusters in the form of lines from a dataset
body: <p>I have a dataset similar to the one shown below, that clearly forms lines from my point of view. Instead of drawing markers, I want to connect the markers within each curve by a line. I am curious, in this case, what type of clustering algorithms would be a good one?</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  np.random.seed = 42
  
  #Generate (x,y) data
  x = np.linspace(0.1,0.9,50)
  y = x%1
  x += np.sin(2*x%1)
  y = y%0.2
  
  #Shuffle (x,y) data
  ns = list(range(len(x)))
  np.random.shuffle(ns)
  x = x[ns]
  y = y[ns]
  
  #Plot
  fig, axs = plt.subplots(1,2)
  axs[0].scatter(x,y)
  axs[1].plot(x,y)
  plt.savefig("markers vs lines.pdf")
  </code></pre>
  
  <p><strong>Figure</strong> - Left: Markers, Right: Data points connected by lines.</p>
  
  <p><a href="https://i.stack.imgur.com/BCwLk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BCwLk.jpg" alt="enter image description here"></a></p>