title: How to smoothen data in Python?
body: <p>I am trying to smoothen a scatter plot shown below using SciPy's B-spline representation of 1-D curve. The data is available <a href="https://drive.google.com/file/d/0BwwhEMUIYGyTaUZ3bThoNXc2UW8/view?usp=sharing" rel="nofollow noreferrer">here</a>.</p>
  
  <p><img src="https://i.stack.imgur.com/0Dbij.png" alt="enter image description here"></p>
  
  <p>The code I used is:</p>
  
  <pre><code>import matplotlib.pyplot as plt
  import numpy as np
  from scipy import interpolate
  
  data = np.genfromtxt("spline_data.dat", delimiter = '\t')
  x = 1000 / data[:, 0]
  y = data[:, 1]
  x_int = np.linspace(x[0], x[-1], 100)
  tck = interpolate.splrep(x, y, k = 3, s = 1)
  y_int = interpolate.splev(x_int, tck, der = 0)
  
  fig = plt.figure(figsize = (5.15,5.15))
  plt.subplot(111)
  plt.plot(x, y, marker = 'o', linestyle='')
  plt.plot(x_int, y_int, linestyle = '-', linewidth = 0.75, color='k')
  plt.xlabel("X")
  plt.ylabel("Y")
  plt.show()
  </code></pre>
  
  <p>I tried changing the order of the spline and the smoothing condition, but I am not getting a smooth plot. </p>
  
  <p><strong><em>B-spline interpolation should be able to smoothen the data but what is wrong? Any alternate method to smoothen this data?</em></strong></p>