I presume that you have already installed python in your PC and added it to system path. And now you want to install one of the best plotting library matplotlib. It is pretty straightforward in a linux-based OS with a package manager. But in Windows –
1) Install distribute: It helps in installing python packages easily. Download file, open windows command prompt or powershell and using ‘cd’ command change to the folder containing the downloaded file, then perform the following command to install distribute –
2) Add easy-install to system PATH: We have to add the Scripts directory to the system path. If you have python 3.3, the path to the Scripts directory is
C:\Python33\Scripts\ The method of adding a directory to system path has already shown in the previous tutorial.
3) Install matplotlib: There are certain dependencies needed to be installed for matplotlib working correctly. But these are no more our concern. The distribute package will check for dependencies and install it automatically. We just have to run this command –
Voila! We have successfully installed matplotlib.
4) Test it: Now start python interpreter and run the following commands to test the plotting library –
>> import pylab >> x = [i/10 for i in range(0, 100)] >> y = [i*i for i in x] >> pylab.plot(x, y) [...] >> pylab.show()
Output of the last command is the following plot –