#! /usr/bin/env python # -*- coding: utf-8 -*- """ A second demo of the MatPlotLib plotting module for Python, to plot the sin and cos functions. @date: Sun Apr 12 20:29:05 2015. @author: Lilian Besson for CS101 course at Mahindra Ecole Centrale 2015. @licence: MIT Licence (http://lbesson.mit-license.org). """ # Usual way to import MatPlotLib and NumPy: import matplotlib.pyplot as plt import numpy as np # 500 points from -4*pi to 4*pi X = np.linspace(-4*np.pi, 4*np.pi, 500) Y1 = np.sin(X) Y2 = np.cos(X) plt.plot(X, Y1, 'k-') # sin(X) as a black continuous line plt.plot(X, Y2, 'b:') # cos(X) as a green dotted line # plt.show() plt.savefig("secondexample.png", dpi=140)