#! /usr/bin/env python # -*- coding: utf-8 -*- """ A simple demo of the MatPlotLib plotting module for Python, to plot the sin function. Adding a title. @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) Y = np.sin(X) plt.plot(X, Y, 'k-') # sin(X) as a black continuous line plt.title(r"The $\sin$ function on $[-4\pi, 4\pi]$") # plt.show() plt.savefig("thirdexample.png", dpi=140)