import numpy as np
from matplotlib import pyplot as plt
x = np.linspace(0,1,100)
y0 = np.sin(2*np.pi*x)
y1 = 0.5*np.sin(6*np.pi*x)
y2 = 0.25*np.sin(10*np.pi*x)
y3 = 0.125*np.sin(14*np.pi*x)
fig,(ax0,ax1) = plt.subplots(2,1)
ax0.plot(x,y0+y1+y2+y3)
ax0.set(xlabel='x',xlim=(0,1),ylim=(-1.1,1.1),title='Signal and its harmonics')
ax0.grid(True)
ax1.plot(x,y0)
ax1.plot(x,y1)
ax1.plot(x,y3)
ax1.plot(x,y3)
ax1.set(xlabel='x',xlim=(0,1),ylim=(-1.1,1.1))
ax1.grid(True)
fig