[Tutorial] Introduction to Numpy and Matplotlib

Introduction to NumPy and Matplotlib – Eric Jones


Eric has a broad background in engineering and software development and leads Enthought’s product engineering and software design. Prior to co-founding Enthought, Eric worked with numerical electromagnetics and genetic optimization in the Department of Electrical Engineering at Duke University. He has taught numerous courses on the use of Python for scientific computing and serves as a member of the Python Software Foundation. He holds M.S. and Ph.D. degrees from Duke University in electrical engineering and a B.S.E. in mechanical engineering from Baylor University


NumPy is the most fundamental package for scientific computing with Python. It adds to the Python language a data structure (the NumPy array) that has access to a large library of mathematical functions and operations, providing a powerful framework for fast computations in multiple dimensions. NumPy is the basis for all SciPy packages which extends vastly the computational and algorithmic capabilities of Python as well as many visualization tools like Matplotlib, Chaco or Mayavi.

This tutorial will teach students the fundamentals of NumPy, including fast vector-based calculations on numpy arrays, the origin of its efficiency and a short introduction to the matplotlib plotting library. In the final section, more advanced concepts will be introduced including structured arrays, broadcasting and memory mapping.


  • NumPy: history and overview
    • History
    • Overview
  • Basic plotting with Matplotlib
    • Basic plotting with Matplotlib
    • 2D plots
    • Histograms
    • Scatter plots
    • Displaying images
  • Fast computations with NumPy arrays
    • Creating NumPy arrays
    • Computations with NumPy arrays
    • Types and shapes of NumPy arrays
    • Built-in operations on a NumPy array
    • Slicing and indexing
    • From data files to arrays and back
  • Advanced concepts
    • The underlying data structure
    • Broadcasting
    • Structured arrays
    • Memory mapped arrays

Required Packages

It requires python 2.6+ or 3.1+, NumPy 1.6.1+, iPython 0.11+, and matplotlib 1.0+ to be installed on your laptop. All these packages are available in various one-click installers including EPDFree.

In addition:

  1. Download and unpack the tutorial files.
    introduction_numpy_matplotlib.zip | 5.7MB ]
  2. To test if your installation is working, follow the indications on page 7 of the manual. The speed of light folder is inside the class folder inside student/demo/speed_of_light/


[1] SciPy 2012 Tutorial: http://conference.scipy.org/scipy2012/tutorials.php#ti-72
[2] Matplotlib for beginner:  http://www.loria.fr/~rougier/teaching/matplotlib/
[3] Matplotlib official website: http://matplotlib.org/index.html


Be Sociable, Share!
Categories: Machine Learning

Leave a Reply