@sines-4.py

from __future__ import print_function
from os import path
import numpy as np
import matplotlib.pyplot as plt
from matplotlib.ticker import MultipleLocatorFormatStrFormatter

ImgsPath = r'C:\CJS\prj\Python\ws\charts\imgs'
fn = 'sines-4.png'

Radians = lambda d: 2.0 * np.pi * (d/360.0)

xmin,xmax = (-12.0 * np.pi), (+12.0 * np.pi)
ymax,ymin = +2.00, -2.00

xt = np.arange(xminxmax0.01)

dxs = []
for ix in range(10):
    n = 1+(1.9*ix)
    dx = [np.sin(x*n) / float(nfor x in xt]
    dxs.append(dx)

dx0 = [sum(dfor d in zip(*dxs)]

figax = plt.subplots()
fig.suptitle('Sine Waves')
ax.set_xlabel('X Axis')
ax.set_ylabel('Y Axis')
ax.set_xlim(xminxmax)
ax.set_ylim(yminymax)
ax.minorticks_on()
ax.xaxis.set_major_locator(MultipleLocator(np.pi * 2))
ax.yaxis.set_major_locator(MultipleLocator(0.25))
ax.xaxis.set_major_formatter(FormatStrFormatter('%.2f'))
ax.yaxis.set_major_formatter(FormatStrFormatter('%+.2f'))
ax.xaxis.set_minor_locator(MultipleLocator(np.pi/4))
ax.yaxis.set_minor_locator(MultipleLocator(0.05))
ax.tick_params(which='major'axis='both'direction='out'zorder=0)
ax.tick_params(which='minor'axis='both'direction='out'zorder=0)
ax.grid(which='minor'axis='both'color='#efefff'lw=0.6,ls='-',zorder=0alpha=1.0)
ax.grid(which='major'axis='both'color='#7f7fbf'lw=1.2,ls='-',zorder=1alpha=1.0)

for ix,dx in enumerate(dxs):
    c = (float(ix+1) / 10.0)
    ax.plot(xt,dxcolor=(c,c,c), lw=0.80zorder=3alpha=0.85)

ax.plot(xt,dx0color='#ff0000'lw=1.60zorder=9alpha=0.85)

fig.set_figwidth(8.0)
fig.set_figheight(4.8)
fig.subplots_adjust(left=0.10bottom=0.10right=0.90top=0.90)

fig.savefig(path.join(ImgsPath,fn))
plt.show()