title: scipy: interpolation, cubic & linear
body: <p>I'm trying to interpolate my set of data (first columnt is the time, third columnt is the actual data):</p>
  
  <pre><code>import numpy as np
  import matplotlib.pyplot as plt
  from scipy.interpolate import interp1d
  
  data = np.genfromtxt("data.csv", delimiter=" ")
  
  x = data[:, 0]
  y = data[:, 2]
  
  xx = np.linspace(x.min(), x.max(), 1000)
  y_smooth = interp1d(x, y)(xx)
  #y_smooth = interp1d(x, y, kind="cubic")(xx)
  
  fig = plt.figure()
  ax = fig.add_subplot(111)
  ax.plot(xx, y_smooth, "r-")
  
  plt.show()
  </code></pre>
  
  <p>but I see some strange difference between linear and cubic interpolation.
  Here is the result for linear:
  <img src="https://i.stack.imgur.com/GvZAa.png" alt="enter image description here"></p>
  
  <p>Here is the same for cubic:
  <img src="https://i.stack.imgur.com/psAbx.png" alt="enter image description here"></p>
  
  <p>I'm not sure, why is graph jumping all the time and <code>y_smooth</code> contains incorrect values?</p>
  
  <pre><code>ipdb&gt; y_smooth_linear.max()
  141.5481144
  ipdb&gt; y_smooth_cubic.max()
  1.2663431888584225e+18
  </code></pre>
  
  <p>Can anybody explain to me, how can I change my code to achieve correct interpolation?</p>
  
  <p><em>UPD</em>: here is <a href="https://www.dropbox.com/s/gds2ny10tbg0ixq/data.csv?dl=1" rel="nofollow noreferrer"><code>data.cvs</code> file</a></p>