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
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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
Image('character.png')

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:

Image('http://www.imagesource.com/Doc/IS0/Media/TR5/7/7/f/4/IS09A9H4K.jpg...