Book Image

IPython Notebook Essentials

By : Luiz Felipe Martins
Book Image

IPython Notebook Essentials

By: Luiz Felipe Martins

Overview of this book

Table of Contents (15 chapters)
IPython Notebook Essentials
About the Author
About the Reviewers

The rich display system

In an exciting development, recent versions of IPython include the capability to display images, video, sound, and other media directly in the notebook. The classes that support the display system are in the IPython.display module. In this section, we will discuss some of the supported formats.

Images and YouTube videos

Images can be loaded either from the local filesystem or from the web. To display the image contained in the character.png file, for example, run the following command in a cell:

from IPython.display import Image

It is also possible to store the image in a variable to be displayed at a later time:

img = Image('character.png')

The character.png file can be downloaded from the web page of this book.

To display the image, we can use either img or display(img). The following image is displayed:

To load an image from the Web, simply give its URL as an argument: