Book Image

Learning IPython for Interactive Computing and Data Visualization, Second Edition

By : Cyrille Rossant
Book Image

Learning IPython for Interactive Computing and Data Visualization, Second Edition

By: Cyrille Rossant

Overview of this book

Python is a user-friendly and powerful programming language. IPython offers a convenient interface to the language and its analysis libraries, while the Jupyter Notebook is a rich environment well-adapted to data science and visualization. Together, these open source tools are widely used by beginners and experts around the world, and in a huge variety of fields and endeavors. This book is a beginner-friendly guide to the Python data analysis platform. After an introduction to the Python language, IPython, and the Jupyter Notebook, you will learn how to analyze and visualize data on real-world examples, how to create graphical user interfaces for image processing in the Notebook, and how to perform fast numerical computations for scientific simulations with NumPy, Numba, Cython, and ipyparallel. By the end of this book, you will be able to perform in-depth analyses of all sorts of data.
Table of Contents (13 chapters)
Learning IPython for Interactive Computing and Data Visualization Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Choosing a plotting backend


There are different ways to display a plot in the Jupyter Notebook.

Inline plots

So far, we have created plots within the Notebook using the matplotlib inline mode. This is activated with the %matplotlib inline magic command in the Notebook. Figures created in this mode are converted to PNG images stored within the notebook .ipynb files. This is convenient when sharing notebooks because the plots are viewable by other users. However, these plots are static, and they are therefore not practical for interactive visualization.

Here is an example:

In [1]: import numpy as np
        import matplotlib.pyplot as plt
In [2]: %matplotlib inline
In [3]: plt.imshow(np.random.rand(10, 10), interpolation='none')

Inline backend

Exported figures

Matplotlib can export figures to bitmap (PNG, JPG, and others) or vector formats (PDF, EPS, and others). Refer to the documentation of plt.savefig() for more details: http://matplotlib.org/api/pyplot_api.html#matplotlib.pyplot.savefig.

GUI...