title: How to get piecewise linear function in Python
body: <p>I would like to get piecewise linear function from set of points. Here is visual example:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  x = [1,2,7,9,11]
  y = [2,5,9,1,11]
  plt.plot(x, y)
  plt.show()
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/xp7vo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/xp7vo.png" alt="piecewise illustration"></a></p>
  
  <p>So I need a function that would take two lists and would return piecewise linear function back. I do not need regression or any kind of least square fit.</p>
  
  <p>I can try to write it myself, but wonder if there is something already written. So far, I only found code returning regression </p>