In [10]:
import numpy as np
import matplotlib.pyplot as plt
import scipy.interpolate as si
%matplotlib inline

Suppose we have some data

In [11]:
x = np.array([0,1,2,3,6,7,8,9])
y = np.array([1,1,1,1,0,0,0,0])
plt.plot(x, y, 'o', ms=20, clip_on=False)
plt.axis('off')
Out[11]:
(0.0, 9.0, 0.0, 1.0)

Should we connect the gaps with straight lines?

In [15]:
plt.plot(x, y, 'o', ms=20, clip_on=False)
plt.plot(x, y, 'g-', ms=20, clip_on=False, lw=6)
plt.axis('off')
Out[15]:
(0.0, 9.0, 0.0, 1.0)

Or should we connect the gaps with something smoother?

In [18]:
f = si.interp1d(x, y, kind='cubic')
xx = np.linspace(x.min(), x.max(), 1000)
plt.plot(x, y, 'o', ms=20, clip_on=False)
plt.plot(xx, f(xx), '-r', ms=20, clip_on=False, lw=6)
plt.axis('off')
Out[18]:
(0.0, 9.0, -0.20000000000000001, 1.2000000000000002)
In [ ]: