Book Image

Learning IPython for Interactive Computing and Data Visualization

By : Cyrille Rossant
Book Image

Learning IPython for Interactive Computing and Data Visualization

By: Cyrille Rossant

Overview of this book

<p>You already use Python as a scripting language, but did you know it is also increasingly used for scientific computing and data analysis? Interactive programming is essential in such exploratory tasks and IPython is the perfect tool for that. Once you’ve learnt it, you won’t be able to live without it.<br /><br />"Learning IPython for Interactive Computing and Data Visualization" is a practical, hands-on, example-driven tutorial to considerably improve your productivity during interactive Python sessions, and shows you how to effectively use IPython for interactive computing and data analysis.<br /><br />This book covers all aspects of IPython, from the highly powerful interactive Python console to the numerical and visualization features that are commonly associated with IPython.</p> <p>You will learn how IPython lets you perform efficient vectorized computations, through examples covering numerical simulations with NumPy, data analysis with Pandas, and visualization with Matplotlib. You will also discover how IPython can be conveniently used to optimize your code using parallel computing and dynamic compilation in C with Cython.</p> <p>"Learning IPython for Interactive Computing and Data Visualization" will allow you to optimize your productivity in interactive Python sessions.</p>
Table of Contents (13 chapters)

Advanced figures and graphics


In this section, we will show more advanced graphical features offered by Matplotlib that are related to images and maps. We will also take a look at a few other graphical libraries.

Image processing

A colored N x M image can be represented as an N x M x 3 NumPy array corresponding to three N x M matrices for the red, green, and blue channels. Image processing algorithms can then be implemented efficiently with NumPy and SciPy and visualized with Matplotlib. In addition, the PIL package (Python Imaging Library) implements basic image processing routines for pictures.

Loading images

Matplotlib's imread function opens a PNG image from the hard drive and returns an N x M x 3 (or N x M x 4 if there is an alpha transparency channel) NumPy array. It can also read other formats if PIL is installed. PIL also offers the open function for reading images in any format (BMP, GIF, JPEG, TIFF, and so on).

In the following example, we download a PNG image from a remote URL and...