title: How to find the data points from a graph
body: <p>Please find the attached graph.
  I need to find the points "a" and "b".
  Kindly suggest any methods in python.</p>
  
  <p>Graph is plotted by obtaining run times, which are observed as below:
  <code>x = ([1000, 2000, 3000, 4000, 5000, 6000,7000, 8000, 9000])</code> and
  <code>y = ([2314,802,519,417,358,318,302,284,280])</code></p>
  
  <p>Need to find out "a" and "b" points so that i can use them individually for other tasks</p>
  
  <p>Full code:</p>
  
  <pre><code>def piecewise_linear(x, x0, y0, k1, k2):
      return np.piecewise(x, [x &lt; x0], [lambda x:k1*x + y0-k1*x0, lambda x:k2*x + y0-k2*x0])
  
  perr_min = np.inf
  p_best = None
  for n in range(100):
      k = np.random.rand(10)*20
      p , e = optimize.curve_fit(piecewise_linear, x, y)
      perr = np.sum(np.abs(y-piecewise_linear(x, *p)))
      if(perr &lt; perr_min):
          print "success"
          perr_min = perr
          p_best = p
  
  xd = np.linspace(min(x), max(x), 100)
  plt.figure()
  plt.plot(x, y, "bo")
  y_out = piecewise_linear(xd, *p_best)
  plt.plot(xd, y_out)
  plt.ylabel('Number of KeyFrames')
  plt.xlabel('Threshold Values')
  plt.show()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Dd7QU.png" rel="nofollow noreferrer">Graph</a></p>