title: Splines with Python (using control knots and endpoints)
body: <p>I'm trying to do something like the following (image extracted from wikipedia)</p>
  
  <p><img src="https://i.stack.imgur.com/c6VFl.png" alt="spline"></p>
  
  <pre><code>#!/usr/bin/env python
  from scipy import interpolate
  import numpy as np
  import matplotlib.pyplot as plt
  
  # sampling
  x = np.linspace(0, 10, 10)
  y = np.sin(x)
  
  # spline trough all the sampled points
  tck = interpolate.splrep(x, y)
  x2 = np.linspace(0, 10, 200)
  y2 = interpolate.splev(x2, tck)
  
  # spline with all the middle points as knots (not working yet)
  # knots = x[1:-1]  # it should be something like this
  knots = np.array([x[1]])  # not working with above line and just seeing what this line does
  weights = np.concatenate(([1],np.ones(x.shape[0]-2)*.01,[1]))
  tck = interpolate.splrep(x, y, t=knots, w=weights)
  x3 = np.linspace(0, 10, 200)
  y3 = interpolate.splev(x2, tck)
  
  # plot
  plt.plot(x, y, 'go', x2, y2, 'b', x3, y3,'r')
  plt.show()
  </code></pre>
  
  <p>The first part of the code is the code extracted from <a href="http://docs.scipy.org/doc/scipy-0.14.0/reference/generated/scipy.interpolate.splrep.html" rel="noreferrer">the main reference</a> but it's not explained how to use the points as control knots.</p>
  
  <p>The result of this code is the following image. </p>
  
  <p><img src="https://i.stack.imgur.com/cbI1l.png" alt="enter image description here"></p>
  
  <p>The points are the samples, the blue line is the spline taking into account all the points. And the red line is the one that is not working for me. I'm trying to take into account <strong>all the intermediate points as control knots</strong> but I just can't. If I try to use <code>knots=x[1:-1]</code> it just doesn't work. I'd appreciate any help.</p>
  
  <p><strong>Question in short</strong>: how do I use all the intermediate points as control knots in the spline function?</p>
  
  <p>Note: this last image is exactly what I need, and it's the difference between what I have (spline passing all the points) and what I need (spline with control knots). Any ideas?
  <img src="https://i.stack.imgur.com/Bnint.gif" alt="enter image description here"></p>