from __future__ import print_function from os import path import numpy as np import matplotlib.pyplot as plt from matplotlib.ticker import MultipleLocator, FormatStrFormatter ImgsPath = r'C:\CJS\prj\Python\ws\charts\imgs' fn = 'sines-1.png' Radians = lambda d: 2.0 * np.pi * (d/360.0) xmin,xmax = (-4.0 * np.pi), (+4.0 * np.pi) ymax,ymin = +2.00, -2.00 xt = np.arange(xmin, xmax, 0.01) dx1 = [np.sin(x*1)/1.0 for x in xt] dx2 = [np.sin(x*3)/3.0 for x in xt] dx3 = [np.sin(x*5)/5.0 for x in xt] dx4 = [np.sin(x*7)/7.0 for x in xt] dx5 = [np.sin(x*9)/9.0 for x in xt] dx6 = [np.sin(x*11)/11.0 for x in xt] dx7 = [np.sin(x*13)/13.0 for x in xt] dx8 = [np.sin(x*15)/15.0 for x in xt] dx9 = [np.sin(x*17)/17.0 for x in xt] dx0 = [sum(t) for t in zip(dx1,dx2,dx3,dx4,dx5,dx6,dx7,dx8,dx9)] fig, ax = plt.subplots() fig.suptitle('Sine Waves') ax.set_xlabel('X Axis') ax.set_ylabel('Y Axis') ax.set_xlim(xmin, xmax) ax.set_ylim(ymin, ymax) 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=0, alpha=1.0) ax.grid(which='major', axis='both', color='#7f7fbf', lw=1.2,ls='-',zorder=1, alpha=1.0) ax.plot(xt,dx1, color='#000000', lw=0.80, zorder=3, alpha=0.85) ax.plot(xt,dx2, color='#1f1f1f', lw=0.80, zorder=3, alpha=0.85) ax.plot(xt,dx3, color='#3f3f3f', lw=0.80, zorder=3, alpha=0.85) ax.plot(xt,dx4, color='#5f5f5f', lw=0.80, zorder=3, alpha=0.85) ax.plot(xt,dx5, color='#7f7f7f', lw=0.80, zorder=3, alpha=0.85) ax.plot(xt,dx6, color='#9f9f9f', lw=0.80, zorder=3, alpha=0.85) ax.plot(xt,dx7, color='#afafaf', lw=0.80, zorder=3, alpha=0.85) ax.plot(xt,dx8, color='#cfcfcf', lw=0.80, zorder=3, alpha=0.85) ax.plot(xt,dx9, color='#dfdfdf', lw=0.80, zorder=3, alpha=0.85) ax.plot(xt,dx0, color='#ff0000', lw=1.60, zorder=9, alpha=0.85) fig.set_figwidth(8.0) fig.set_figheight(4.8) fig.subplots_adjust(left=0.10, bottom=0.10, right=0.90, top=0.90) fig.savefig(path.join(ImgsPath,fn)) #plt.show()