Important

This documentation covers IPython versions 6.0 and higher. Beginning with version 6.0, IPython stopped supporting compatibility with Python versions lower than 3.3 including all versions of Python 2.7.

If you are looking for an IPython version compatible with Python 2.7, please use the IPython 5.x LTS release and refer to its documentation (LTS is the long term support release).

Module: display

Public API for display tools in IPython.

23 Classes

class IPython.display.Audio(data=None, filename=None, url=None, embed=None, rate=None, autoplay=False, normalize=True, *, element_id=None)

Bases: DisplayObject

Create an audio object.

When this object is returned by an input cell or passed to the display function, it will result in Audio controls being displayed in the frontend (only works in the notebook).

Parameters:
  • data (numpy array, list, unicode, str or bytes) –

    Can be one of

    • Numpy 1d array containing the desired waveform (mono)

    • Numpy 2d array containing waveforms for each channel. Shape=(NCHAN, NSAMPLES). For the standard channel order, see http://msdn.microsoft.com/en-us/library/windows/hardware/dn653308(v=vs.85).aspx

    • List of float or integer representing the waveform (mono)

    • String containing the filename

    • Bytestring containing raw PCM data or

    • URL pointing to a file on the web.

    If the array option is used, the waveform will be normalized.

    If a filename or url is used, the format support will be browser dependent.

  • url (unicode) – A URL to download the data from.

  • filename (unicode) – Path to a local file to load the data from.

  • embed (boolean) –

    Should the audio data be embedded using a data URI (True) or should the original source be referenced. Set this to True if you want the audio to playable later with no internet connection in the notebook.

    Default is True, unless the keyword argument url is set, then default value is False.

  • rate (integer) – The sampling rate of the raw data. Only required when data parameter is being used as an array

  • autoplay (bool) – Set to True if the audio should immediately start playing. Default is False.

  • normalize (bool) – Whether audio should be normalized (rescaled) to the maximum possible range. Default is True. When set to False, data must be between -1 and 1 (inclusive), otherwise an error is raised. Applies only when data is a list or array of samples; other types of audio are never normalized.

Examples

>>> import pytest
>>> np = pytest.importorskip("numpy")

Generate a sound

>>> import numpy as np
>>> framerate = 44100
>>> t = np.linspace(0,5,framerate*5)
>>> data = np.sin(2*np.pi*220*t) + np.sin(2*np.pi*224*t)
>>> Audio(data, rate=framerate)
<IPython.lib.display.Audio object>

Can also do stereo or more channels

>>> dataleft = np.sin(2*np.pi*220*t)
>>> dataright = np.sin(2*np.pi*224*t)
>>> Audio([dataleft, dataright], rate=framerate)
<IPython.lib.display.Audio object>

From URL:

>>> Audio("http://www.nch.com.au/acm/8k16bitpcm.wav")  
>>> Audio(url="http://www.w3schools.com/html/horse.ogg")  

From a File:

>>> Audio('IPython/lib/tests/test.wav')  
>>> Audio(filename='IPython/lib/tests/test.wav')  

From Bytes:

>>> Audio(b'RAW_WAV_DATA..')  
>>> Audio(data=b'RAW_WAV_DATA..')  

See also

ipywidgets.Audio

Audio widget with more more flexibility and options.

__init__(data=None, filename=None, url=None, embed=None, rate=None, autoplay=False, normalize=True, *, element_id=None)

Create a display object given raw data.

When this object is returned by an expression or passed to the display function, it will result in the data being displayed in the frontend. The MIME type of the data should match the subclasses used, so the Png subclass should be used for ‘image/png’ data. If the data is a URL, the data will first be downloaded and then displayed.

Parameters:
  • data (unicode, str or bytes) – The raw data or a URL or file to load the data from

  • url (unicode) – A URL to download the data from.

  • filename (unicode) – Path to a local file to load the data from.

  • metadata (dict) – Dict of metadata associated to be the object when displayed

reload()

Reload the raw data from file or URL.

class IPython.display.Code(data=None, url=None, filename=None, language=None)

Bases: TextDisplayObject

Display syntax-highlighted source code.

This uses Pygments to highlight the code for HTML and Latex output.

Parameters:
  • data (str) – The code as a string

  • url (str) – A URL to fetch the code from

  • filename (str) – A local filename to load the code from

  • language (str) – The short name of a Pygments lexer to use for highlighting. If not specified, it will guess the lexer based on the filename or the code. Available lexers: http://pygments.org/docs/lexers/

__init__(data=None, url=None, filename=None, language=None)

Create a display object given raw data.

When this object is returned by an expression or passed to the display function, it will result in the data being displayed in the frontend. The MIME type of the data should match the subclasses used, so the Png subclass should be used for ‘image/png’ data. If the data is a URL, the data will first be downloaded and then displayed.

Parameters:
  • data (unicode, str or bytes) – The raw data or a URL or file to load the data from

  • url (unicode) – A URL to download the data from.

  • filename (unicode) – Path to a local file to load the data from.

  • metadata (dict) – Dict of metadata associated to be the object when displayed

class IPython.display.DisplayHandle(display_id=None)

Bases: object

A handle on an updatable display

Call .update(obj) to display a new object.

Call .display(obj) to add a new instance of this display, and update existing instances.

__init__(display_id=None)
display(obj, **kwargs)

Make a new display with my id, updating existing instances.

Parameters:
  • obj – object to display

  • **kwargs – additional keyword arguments passed to display

update(obj, **kwargs)

Update existing displays with my id

Parameters:
  • obj – object to display

  • **kwargs – additional keyword arguments passed to update_display

class IPython.display.DisplayObject(data=None, url=None, filename=None, metadata=None)

Bases: object

An object that wraps data to be displayed.

__init__(data=None, url=None, filename=None, metadata=None)

Create a display object given raw data.

When this object is returned by an expression or passed to the display function, it will result in the data being displayed in the frontend. The MIME type of the data should match the subclasses used, so the Png subclass should be used for ‘image/png’ data. If the data is a URL, the data will first be downloaded and then displayed.

Parameters:
  • data (unicode, str or bytes) – The raw data or a URL or file to load the data from

  • url (unicode) – A URL to download the data from.

  • filename (unicode) – Path to a local file to load the data from.

  • metadata (dict) – Dict of metadata associated to be the object when displayed

reload()

Reload the raw data from file or URL.

Bases: object

Class for embedding a local file link in an IPython session, based on path

e.g. to embed a link that was generated in the IPython notebook as my/data.txt

you would do:

local_file = FileLink("my/data.txt")
display(local_file)

or in the HTML notebook, just:

FileLink("my/data.txt")
__init__(path, url_prefix='', result_html_prefix='', result_html_suffix='<br>')
Parameters:
  • path (str) – path to the file or directory that should be formatted

  • url_prefix (str) – prefix to be prepended to all files to form a working link [default: ‘’]

  • result_html_prefix (str) – text to append to beginning to link [default: ‘’]

  • result_html_suffix (str) – text to append at the end of link [default: ‘<br>’]

Bases: FileLink

Class for embedding local file links in an IPython session, based on path

e.g. to embed links to files that were generated in the IPython notebook under my/data, you would do:

local_files = FileLinks("my/data")
display(local_files)

or in the HTML notebook, just:

FileLinks("my/data")
__init__(path, url_prefix='', included_suffixes=None, result_html_prefix='', result_html_suffix='<br>', notebook_display_formatter=None, terminal_display_formatter=None, recursive=True)

See FileLink for the path, url_prefix, result_html_prefix and result_html_suffix parameters.

included_suffixeslist

Filename suffixes to include when formatting output [default: include all files]

notebook_display_formatterfunction

Used to format links for display in the notebook. See discussion of formatter functions below.

terminal_display_formatterfunction

Used to format links for display in the terminal. See discussion of formatter functions below.

Formatter functions must be of the form:

f(dirname, fnames, included_suffixes)
dirnamestr

The name of a directory

fnameslist

The files in that directory

included_suffixeslist

The file suffixes that should be included in the output (passing None meansto include all suffixes in the output in the built-in formatters)

recursiveboolean

Whether to recurse into subdirectories. Default is True.

The function should return a list of lines that will be printed in the notebook (if passing notebook_display_formatter) or the terminal (if passing terminal_display_formatter). This function is iterated over for each directory in self.path. Default formatters are in place, can be passed here to support alternative formatting.

class IPython.display.GeoJSON(*args, **kwargs)

Bases: JSON

GeoJSON expects JSON-able dict

not an already-serialized JSON string.

Scalar types (None, number, string) are not allowed, only dict containers.

__init__(*args, **kwargs)

Create a GeoJSON display object given raw data.

Parameters:

Examples

The following will display an interactive map of Mars with a point of interest on frontend that do support GeoJSON display.

>>> from IPython.display import GeoJSON
>>> GeoJSON(data={
...     "type": "Feature",
...     "geometry": {
...         "type": "Point",
...         "coordinates": [-81.327, 296.038]
...     }
... },
... url_template="http://s3-eu-west-1.amazonaws.com/whereonmars.cartodb.net/{basemap_id}/{z}/{x}/{y}.png",
... layer_options={
...     "basemap_id": "celestia_mars-shaded-16k_global",
...     "attribution" : "Celestia/praesepe",
...     "minZoom" : 0,
...     "maxZoom" : 18,
... })
<IPython.core.display.GeoJSON object>

In the terminal IPython, you will only see the text representation of the GeoJSON object.

class IPython.display.HTML(data=None, url=None, filename=None, metadata=None)

Bases: TextDisplayObject

__init__(data=None, url=None, filename=None, metadata=None)

Create a display object given raw data.

When this object is returned by an expression or passed to the display function, it will result in the data being displayed in the frontend. The MIME type of the data should match the subclasses used, so the Png subclass should be used for ‘image/png’ data. If the data is a URL, the data will first be downloaded and then displayed.

Parameters:
  • data (unicode, str or bytes) – The raw data or a URL or file to load the data from

  • url (unicode) – A URL to download the data from.

  • filename (unicode) – Path to a local file to load the data from.

  • metadata (dict) – Dict of metadata associated to be the object when displayed

class IPython.display.IFrame(src, width, height, extras: Iterable[str] | None = None, **kwargs)

Bases: object

Generic class to embed an iframe in an IPython notebook

__init__(src, width, height, extras: Iterable[str] | None = None, **kwargs)
class IPython.display.Image(data=None, url=None, filename=None, format=None, embed=None, width=None, height=None, retina=False, unconfined=False, metadata=None, alt=None)

Bases: DisplayObject

__init__(data=None, url=None, filename=None, format=None, embed=None, width=None, height=None, retina=False, unconfined=False, metadata=None, alt=None)

Create a PNG/JPEG/GIF image object given raw data.

When this object is returned by an input cell or passed to the display function, it will result in the image being displayed in the frontend.

Parameters:
  • data (unicode, str or bytes) – The raw image data or a URL or filename to load the data from. This always results in embedded image data.

  • url (unicode) – A URL to download the data from. If you specify url=, the image data will not be embedded unless you also specify embed=True.

  • filename (unicode) – Path to a local file to load the data from. Images from a file are always embedded.

  • format (unicode) – The format of the image data (png/jpeg/jpg/gif). If a filename or URL is given for format will be inferred from the filename extension.

  • embed (bool) –

    Should the image data be embedded using a data URI (True) or be loaded using an <img> tag. Set this to True if you want the image to be viewable later with no internet connection in the notebook.

    Default is True, unless the keyword argument url is set, then default value is False.

    Note that QtConsole is not able to display images if embed is set to False

  • width (int) – Width in pixels to which to constrain the image in html

  • height (int) – Height in pixels to which to constrain the image in html

  • retina (bool) – Automatically set the width and height to half of the measured width and height. This only works for embedded images because it reads the width/height from image data. For non-embedded images, you can just set the desired display width and height directly.

  • unconfined (bool) – Set unconfined=True to disable max-width confinement of the image.

  • metadata (dict) – Specify extra metadata to attach to the image.

  • alt (unicode) – Alternative text for the image, for use by screen readers.

Examples

embedded image data, works in qtconsole and notebook when passed positionally, the first arg can be any of raw image data, a URL, or a filename from which to load image data. The result is always embedding image data for inline images.

>>> Image('https://www.google.fr/images/srpr/logo3w.png') 
<IPython.core.display.Image object>
>>> Image('/path/to/image.jpg')
<IPython.core.display.Image object>
>>> Image(b'RAW_PNG_DATA...')
<IPython.core.display.Image object>

Specifying Image(url=…) does not embed the image data, it only generates <img> tag with a link to the source. This will not work in the qtconsole or offline.

>>> Image(url='https://www.google.fr/images/srpr/logo3w.png')
<IPython.core.display.Image object>
reload()

Reload the raw data from file or URL.

class IPython.display.JSON(data=None, url=None, filename=None, expanded=False, metadata=None, root='root', **kwargs)

Bases: DisplayObject

JSON expects a JSON-able dict or list

not an already-serialized JSON string.

Scalar types (None, number, string) are not allowed, only dict or list containers.

__init__(data=None, url=None, filename=None, expanded=False, metadata=None, root='root', **kwargs)

Create a JSON display object given raw data.

Parameters:
  • data (dict or list) – JSON data to display. Not an already-serialized JSON string. Scalar types (None, number, string) are not allowed, only dict or list containers.

  • url (unicode) – A URL to download the data from.

  • filename (unicode) – Path to a local file to load the data from.

  • expanded (boolean) – Metadata to control whether a JSON display component is expanded.

  • metadata (dict) – Specify extra metadata to attach to the json display object.

  • root (str) – The name of the root element of the JSON tree

class IPython.display.Javascript(data=None, url=None, filename=None, lib=None, css=None)

Bases: TextDisplayObject

__init__(data=None, url=None, filename=None, lib=None, css=None)

Create a Javascript display object given raw data.

When this object is returned by an expression or passed to the display function, it will result in the data being displayed in the frontend. If the data is a URL, the data will first be downloaded and then displayed.

In the Notebook, the containing element will be available as element, and jQuery will be available. Content appended to element will be visible in the output area.

Parameters:
  • data (unicode, str or bytes) – The Javascript source code or a URL to download it from.

  • url (unicode) – A URL to download the data from.

  • filename (unicode) – Path to a local file to load the data from.

  • lib (list or str) – A sequence of Javascript library URLs to load asynchronously before running the source code. The full URLs of the libraries should be given. A single Javascript library URL can also be given as a string.

  • css (list or str) – A sequence of css files to load before running the source code. The full URLs of the css files should be given. A single css URL can also be given as a string.

class IPython.display.Latex(data=None, url=None, filename=None, metadata=None)

Bases: TextDisplayObject

class IPython.display.Markdown(data=None, url=None, filename=None, metadata=None)

Bases: TextDisplayObject

class IPython.display.Math(data=None, url=None, filename=None, metadata=None)

Bases: TextDisplayObject

class IPython.display.Pretty(data=None, url=None, filename=None, metadata=None)

Bases: TextDisplayObject

class IPython.display.ProgressBar(total)

Bases: DisplayObject

Progressbar supports displaying a progressbar like element

__init__(total)

Creates a new progressbar

Parameters:

total (int) – maximum size of the progressbar

class IPython.display.SVG(data=None, url=None, filename=None, metadata=None)

Bases: DisplayObject

Embed an SVG into the display.

Note if you just want to view a svg image via a URL use :class:Image with a url=URL keyword argument.

class IPython.display.ScribdDocument(id, width=400, height=300, **kwargs)

Bases: IFrame

Class for embedding a Scribd document in an IPython session

Use the start_page params to specify a starting point in the document Use the view_mode params to specify display type one off scroll | slideshow | book

e.g to Display Wes’ foundational paper about PANDAS in book mode from page 3

ScribdDocument(71048089, width=800, height=400, start_page=3, view_mode=”book”)

__init__(id, width=400, height=300, **kwargs)
class IPython.display.TextDisplayObject(data=None, url=None, filename=None, metadata=None)

Bases: DisplayObject

Create a text display object given raw data.

Parameters:
  • data (str or unicode) – The raw data or a URL or file to load the data from.

  • url (unicode) – A URL to download the data from.

  • filename (unicode) – Path to a local file to load the data from.

  • metadata (dict) – Dict of metadata associated to be the object when displayed

class IPython.display.Video(data=None, url=None, filename=None, embed=False, mimetype=None, width=None, height=None, html_attributes='controls')

Bases: DisplayObject

__init__(data=None, url=None, filename=None, embed=False, mimetype=None, width=None, height=None, html_attributes='controls')

Create a video object given raw data or an URL.

When this object is returned by an input cell or passed to the display function, it will result in the video being displayed in the frontend.

Parameters:
  • data (unicode, str or bytes) – The raw video data or a URL or filename to load the data from. Raw data will require passing embed=True.

  • url (unicode) – A URL for the video. If you specify url=, the image data will not be embedded.

  • filename (unicode) – Path to a local file containing the video. Will be interpreted as a local URL unless embed=True.

  • embed (bool) –

    Should the video be embedded using a data URI (True) or be loaded using a <video> tag (False).

    Since videos are large, embedding them should be avoided, if possible. You must confirm embedding as your intention by passing embed=True.

    Local files can be displayed with URLs without embedding the content, via:

    Video('./video.mp4')
    

  • mimetype (unicode) – Specify the mimetype for embedded videos. Default will be guessed from file extension, if available.

  • width (int) – Width in pixels to which to constrain the video in HTML. If not supplied, defaults to the width of the video.

  • height (int) – Height in pixels to which to constrain the video in html. If not supplied, defaults to the height of the video.

  • html_attributes (str) – Attributes for the HTML <video> block. Default: "controls" to get video controls. Other examples: "controls muted" for muted video with controls, "loop autoplay" for looping autoplaying video without controls.

Examples

Video('https://archive.org/download/Sita_Sings_the_Blues/Sita_Sings_the_Blues_small.mp4')
Video('path/to/video.mp4')
Video('path/to/video.mp4', embed=True)
Video('path/to/video.mp4', embed=True, html_attributes="controls muted autoplay")
Video(b'raw-videodata', embed=True)
reload()

Reload the raw data from file or URL.

class IPython.display.VimeoVideo(id, width=400, height=300, **kwargs)

Bases: IFrame

Class for embedding a Vimeo video in an IPython session, based on its video id.

__init__(id, width=400, height=300, **kwargs)
class IPython.display.YouTubeVideo(id, width=400, height=300, allow_autoplay=False, **kwargs)

Bases: IFrame

Class for embedding a YouTube Video in an IPython session, based on its video id.

e.g. to embed the video from https://www.youtube.com/watch?v=foo , you would do:

vid = YouTubeVideo("foo")
display(vid)

To start from 30 seconds:

vid = YouTubeVideo("abc", start=30)
display(vid)

To calculate seconds from time as hours, minutes, seconds use datetime.timedelta:

start=int(timedelta(hours=1, minutes=46, seconds=40).total_seconds())

Other parameters can be provided as documented at https://developers.google.com/youtube/player_parameters#Parameters

When converting the notebook using nbconvert, a jpeg representation of the video will be inserted in the document.

__init__(id, width=400, height=300, allow_autoplay=False, **kwargs)

16 Functions

IPython.display.clear_output(wait=False)

Clear the output of the current cell receiving output.

Parameters:

wait (bool [default: false]) – Wait to clear the output until new output is available to replace it.

IPython.display.display(*objs, include=None, exclude=None, metadata=None, transient=None, display_id=None, raw=False, clear=False, **kwargs)

Display a Python object in all frontends.

By default all representations will be computed and sent to the frontends. Frontends can decide which representation is used and how.

In terminal IPython this will be similar to using print(), for use in richer frontends see Jupyter notebook examples with rich display logic.

Parameters:
  • *objs (object) – The Python objects to display.

  • raw (bool, optional) – Are the objects to be displayed already mimetype-keyed dicts of raw display data, or Python objects that need to be formatted before display? [default: False]

  • include (list, tuple or set, optional) – A list of format type strings (MIME types) to include in the format data dict. If this is set only the format types included in this list will be computed.

  • exclude (list, tuple or set, optional) – A list of format type strings (MIME types) to exclude in the format data dict. If this is set all format types will be computed, except for those included in this argument.

  • metadata (dict, optional) – A dictionary of metadata to associate with the output. mime-type keys in this dictionary will be associated with the individual representation formats, if they exist.

  • transient (dict, optional) – A dictionary of transient data to associate with the output. Data in this dict should not be persisted to files (e.g. notebooks).

  • display_id (str, bool optional) – Set an id for the display. This id can be used for updating this display area later via update_display. If given as True, generate a new display_id

  • clear (bool, optional) – Should the output area be cleared before displaying anything? If True, this will wait for additional output before clearing. [default: False]

  • **kwargs (additional keyword-args, optional) – Additional keyword-arguments are passed through to the display publisher.

Returns:

handle – Returns a handle on updatable displays for use with update_display(), if display_id is given. Returns None if no display_id is given (default).

Return type:

DisplayHandle

Examples

>>> class Json(object):
...     def __init__(self, json):
...         self.json = json
...     def _repr_pretty_(self, pp, cycle):
...         import json
...         pp.text(json.dumps(self.json, indent=2))
...     def __repr__(self):
...         return str(self.json)
...
>>> d = Json({1:2, 3: {4:5}})
>>> print(d)
{1: 2, 3: {4: 5}}
>>> display(d)
{
  "1": 2,
  "3": {
    "4": 5
  }
}
>>> def int_formatter(integer, pp, cycle):
...     pp.text('I'*integer)
>>> plain = get_ipython().display_formatter.formatters['text/plain']
>>> plain.for_type(int, int_formatter)
<function _repr_pprint at 0x...>
>>> display(7-5)
II
>>> del plain.type_printers[int]
>>> display(7-5)
2

See also

update_display()

Notes

In Python, objects can declare their textual representation using the __repr__ method. IPython expands on this idea and allows objects to declare other, rich representations including:

  • HTML

  • JSON

  • PNG

  • JPEG

  • SVG

  • LaTeX

A single object can declare some or all of these representations; all are handled by IPython’s display system.

The main idea of the first approach is that you have to implement special display methods when you define your class, one for each representation you want to use. Here is a list of the names of the special methods and the values they must return:

  • _repr_html_: return raw HTML as a string, or a tuple (see below).

  • _repr_json_: return a JSONable dict, or a tuple (see below).

  • _repr_jpeg_: return raw JPEG data, or a tuple (see below).

  • _repr_png_: return raw PNG data, or a tuple (see below).

  • _repr_svg_: return raw SVG data as a string, or a tuple (see below).

  • _repr_latex_: return LaTeX commands in a string surrounded by “$”,

    or a tuple (see below).

  • _repr_mimebundle_: return a full mimebundle containing the mapping

    from all mimetypes to data. Use this for any mime-type not listed above.

The above functions may also return the object’s metadata alonside the data. If the metadata is available, the functions will return a tuple containing the data and metadata, in that order. If there is no metadata available, then the functions will return the data only.

When you are directly writing your own classes, you can adapt them for display in IPython by following the above approach. But in practice, you often need to work with existing classes that you can’t easily modify.

You can refer to the documentation on integrating with the display system in order to register custom formatters for already existing types (Rich display).

Added in version 5.4: display available without import

Added in version 6.1: display available without import

Since IPython 5.4 and 6.1 display() is automatically made available to the user without import. If you are using display in a document that might be used in a pure python context or with older version of IPython, use the following import at the top of your file:

from IPython.display import display
IPython.display.display_html(*objs, **kwargs)

Display the HTML representation of an object.

Note: If raw=False and the object does not have a HTML representation, no HTML will be shown.

Parameters:
  • *objs (object) – The Python objects to display, or if raw=True raw HTML data to display.

  • raw (bool) – Are the data objects raw data or Python objects that need to be formatted before display? [default: False]

  • metadata (dict (optional)) – Metadata to be associated with the specific mimetype output.

IPython.display.display_javascript(*objs, **kwargs)

Display the Javascript representation of an object.

Parameters:
  • *objs (object) – The Python objects to display, or if raw=True raw javascript data to display.

  • raw (bool) – Are the data objects raw data or Python objects that need to be formatted before display? [default: False]

  • metadata (dict (optional)) – Metadata to be associated with the specific mimetype output.

IPython.display.display_jpeg(*objs, **kwargs)

Display the JPEG representation of an object.

Parameters:
  • *objs (object) – The Python objects to display, or if raw=True raw JPEG data to display.

  • raw (bool) – Are the data objects raw data or Python objects that need to be formatted before display? [default: False]

  • metadata (dict (optional)) – Metadata to be associated with the specific mimetype output.

IPython.display.display_json(*objs, **kwargs)

Display the JSON representation of an object.

Note that not many frontends support displaying JSON.

Parameters:
  • *objs (object) – The Python objects to display, or if raw=True raw json data to display.

  • raw (bool) – Are the data objects raw data or Python objects that need to be formatted before display? [default: False]

  • metadata (dict (optional)) – Metadata to be associated with the specific mimetype output.

IPython.display.display_latex(*objs, **kwargs)

Display the LaTeX representation of an object.

Parameters:
  • *objs (object) – The Python objects to display, or if raw=True raw latex data to display.

  • raw (bool) – Are the data objects raw data or Python objects that need to be formatted before display? [default: False]

  • metadata (dict (optional)) – Metadata to be associated with the specific mimetype output.

IPython.display.display_markdown(*objs, **kwargs)

Displays the Markdown representation of an object.

Parameters:
  • *objs (object) – The Python objects to display, or if raw=True raw markdown data to display.

  • raw (bool) – Are the data objects raw data or Python objects that need to be formatted before display? [default: False]

  • metadata (dict (optional)) – Metadata to be associated with the specific mimetype output.

IPython.display.display_pdf(*objs, **kwargs)

Display the PDF representation of an object.

Parameters:
  • *objs (object) – The Python objects to display, or if raw=True raw javascript data to display.

  • raw (bool) – Are the data objects raw data or Python objects that need to be formatted before display? [default: False]

  • metadata (dict (optional)) – Metadata to be associated with the specific mimetype output.

IPython.display.display_png(*objs, **kwargs)

Display the PNG representation of an object.

Parameters:
  • *objs (object) – The Python objects to display, or if raw=True raw png data to display.

  • raw (bool) – Are the data objects raw data or Python objects that need to be formatted before display? [default: False]

  • metadata (dict (optional)) – Metadata to be associated with the specific mimetype output.

IPython.display.display_pretty(*objs, **kwargs)

Display the pretty (default) representation of an object.

Parameters:
  • *objs (object) – The Python objects to display, or if raw=True raw text data to display.

  • raw (bool) – Are the data objects raw data or Python objects that need to be formatted before display? [default: False]

  • metadata (dict (optional)) – Metadata to be associated with the specific mimetype output.

IPython.display.display_svg(*objs, **kwargs)

Display the SVG representation of an object.

Parameters:
  • *objs (object) – The Python objects to display, or if raw=True raw svg data to display.

  • raw (bool) – Are the data objects raw data or Python objects that need to be formatted before display? [default: False]

  • metadata (dict (optional)) – Metadata to be associated with the specific mimetype output.

IPython.display.publish_display_data(data, metadata=None, source=<deprecated>, *, transient=None, **kwargs)

Publish data and metadata to all frontends.

See the display_data message in the messaging documentation for more details about this message type.

Keys of data and metadata can be any mime-type.

Parameters:
  • data (dict) – A dictionary having keys that are valid MIME types (like ‘text/plain’ or ‘image/svg+xml’) and values that are the data for that MIME type. The data itself must be a JSON’able data structure. Minimally all data should have the ‘text/plain’ data, which can be displayed by all frontends. If more than the plain text is given, it is up to the frontend to decide which representation to use.

  • metadata (dict) – A dictionary for metadata related to the data. This can contain arbitrary key, value pairs that frontends can use to interpret the data. mime-type keys matching those in data can be used to specify metadata about particular representations.

  • source (str, deprecated) – Unused.

  • transient (dict, keyword-only) – A dictionary of transient data, such as display_id.

IPython.display.set_matplotlib_close(close=True)

Deprecated since version 7.23: use matplotlib_inline.backend_inline.set_matplotlib_close()

Set whether the inline backend closes all figures automatically or not.

By default, the inline backend used in the IPython Notebook will close all matplotlib figures automatically after each cell is run. This means that plots in different cells won’t interfere. Sometimes, you may want to make a plot in one cell and then refine it in later cells. This can be accomplished by:

In [1]: set_matplotlib_close(False)

To set this in your config files use the following:

c.InlineBackend.close_figures = False
Parameters:

close (bool) – Should all matplotlib figures be automatically closed after each cell is run?

IPython.display.set_matplotlib_formats(*formats, **kwargs)

Deprecated since version 7.23: use matplotlib_inline.backend_inline.set_matplotlib_formats()

Select figure formats for the inline backend. Optionally pass quality for JPEG.

For example, this enables PNG and JPEG output with a JPEG quality of 90%:

In [1]: set_matplotlib_formats('png', 'jpeg', quality=90)

To set this in your config files use the following:

c.InlineBackend.figure_formats = {'png', 'jpeg'}
c.InlineBackend.print_figure_kwargs.update({'quality' : 90})
Parameters:
  • *formats (strs) – One or more figure formats to enable: ‘png’, ‘retina’, ‘jpeg’, ‘svg’, ‘pdf’.

  • **kwargs – Keyword args will be relayed to figure.canvas.print_figure.

IPython.display.update_display(obj, *, display_id, **kwargs)

Update an existing display by id

Parameters:
  • obj – The object with which to update the display

  • display_id (keyword-only) – The id of the display to update

See also

display()