{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# Custom Display Logic" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Overview" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As described in the [Rich Output](Rich%20Output.ipynb) tutorial, the IPython display system can display rich representations of objects in the following formats:\n", "\n", "* JavaScript\n", "* HTML\n", "* PNG\n", "* JPEG\n", "* SVG\n", "* LaTeX\n", "* PDF\n", "\n", "This Notebook shows how you can add custom display logic to your own classes, so that they can be displayed using these rich representations. There are two ways of accomplishing this:\n", "\n", "1. Implementing special display methods such as `_repr_html_` when you define your class.\n", "2. Registering a display function for a particular existing class.\n", "\n", "This Notebook describes and illustrates both approaches." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Import the IPython display functions." ] }, { "cell_type": "code", "execution_count": 1, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from IPython.display import (\n", " display, display_html, display_png, display_svg\n", ")" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Parts of this notebook need the matplotlib inline backend:" ] }, { "cell_type": "code", "execution_count": 2, "metadata": { "collapsed": false }, "outputs": [], "source": [ "%matplotlib inline\n", "import numpy as np\n", "import matplotlib.pyplot as plt" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Special display methods" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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:\n", "\n", "* `_repr_html_`: return raw HTML as a string\n", "* `_repr_json_`: return a JSONable dict\n", "* `_repr_jpeg_`: return raw JPEG data\n", "* `_repr_png_`: return raw PNG data\n", "* `_repr_svg_`: return raw SVG data as a string\n", "* `_repr_latex_`: return LaTeX commands in a string surrounded by \"$\"." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "As an illustration, we build a class that holds data generated by sampling a Gaussian distribution with given mean and standard deviation. Here is the definition of the `Gaussian` class, which has a custom PNG and LaTeX representation." ] }, { "cell_type": "code", "execution_count": 3, "metadata": { "collapsed": false }, "outputs": [], "source": [ "from IPython.core.pylabtools import print_figure\n", "from IPython.display import Image, SVG, Math\n", "\n", "class Gaussian(object):\n", " \"\"\"A simple object holding data sampled from a Gaussian distribution.\n", " \"\"\"\n", " def __init__(self, mean=0.0, std=1, size=1000):\n", " self.data = np.random.normal(mean, std, size)\n", " self.mean = mean\n", " self.std = std\n", " self.size = size\n", " # For caching plots that may be expensive to compute\n", " self._png_data = None\n", " \n", " def _figure_data(self, format):\n", " fig, ax = plt.subplots()\n", " ax.hist(self.data, bins=50)\n", " ax.set_title(self._repr_latex_())\n", " ax.set_xlim(-10.0,10.0)\n", " data = print_figure(fig, format)\n", " # We MUST close the figure, otherwise IPython's display machinery\n", " # will pick it up and send it as output, resulting in a double display\n", " plt.close(fig)\n", " return data\n", " \n", " def _repr_png_(self):\n", " if self._png_data is None:\n", " self._png_data = self._figure_data('png')\n", " return self._png_data\n", " \n", " def _repr_latex_(self):\n", " return r'$\\mathcal{N}(\\mu=%.2g, \\sigma=%.2g),\\ N=%d$' % (self.mean,\n", " self.std, self.size)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create an instance of the Gaussian distribution and return it to display the default representation:" ] }, { "cell_type": "code", "execution_count": 4, "metadata": { "collapsed": false }, "outputs": [ { "data": { "image/png": [ "iVBORw0KGgoAAAANSUhEUgAAAlEAAAGLCAYAAADnMccKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\n", "AAALEgAACxIB0t1+/AAAGsJJREFUeJzt3X2QndddH/DvsUQs5cXIRoCNA9mGGIR5Dy9KiBMnMmnq\n", "BAbamjOdYIOBafEMGd4MocEGUrAbG1Sgw7sLwWAI5bhT6tC0abCN4rQlSjEhmVAbG1yRRHgTYgsp\n", "xEKOlKd/3LvmeiOvdo/26t6VPp9/ds9znufe32rvaL/znHOeU4ZhCAAAa3PWrAsAANiIhCgAgA5C\n", "FABAByEKAKCDEAUA0EGIAgDoIEQBAHQQogAAOghRsIGVUraMv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vGTffmuT3k9yS5FiS+5Nc\n", "01obplYhwGlocr+863YtHJx1PcDareZO1N7W2uVLjVrrf0tyRWttsdZ6bZIrk9w2rQIBAObRakLU\n", "F9da70ny8STfnuSx1triuO+2JDdHiAIAzjCrmVj+3NbaS5K8LsmtSR6Z6HskyXlTqAsAYK6dMES1\n", "1h4ff31XkseTfNpE9/Ykj06nNACA+bViiKq17qy1XjH+/vlJ9ifZUmu9YHzKVUnunG6JAADz50Rz\n", "ou5L8sO11tdkdMfpmoyG726vtR5Lcl9rbfeUawQAmDsrhqjW2qEk37Ds8IeTXDK1igAANgBPLAcA\n", "6CBEAQB0sO0LwJRs27p5xx33PrQnSc4/5+x9Oy+68OrZVgSsJyEKYEoOHD665cbx1i7X71qYcTXA\n", "ejOcBwDQQYgCAOggRAEAdBCiAAA6mFgOcApMrtRLkk1nlR0zLAdYB0IUwCkwuVIvSa7btXBwlvUA\n", "J89wHgBAByEKAKCDEAUA0EGIAgDoYGI5wBxbvqrPHnwwP4QogDm2fFWfPfhgfhjOAwDoIEQBAHQQ\n", "ogAAOghRAAAdhCgAgA5CFABAByEKAKCDEAUA0EGIAgDo4InlABvU3gf337p46MjCUtuWMHBqCVEA\n", "G9TioSMLN9gSBmbGcB4AQAchCgCggxAFANBBiAIA6GBiOcAGsm3r5h133PvQniTZdFbZMeNy4Iwm\n", "RAFsIAcOH91y43hF3nW7Fg7Ouh44kxnOAwDoIEQBAHQQogAAOghRAAAdhCgAgA5CFABAByEKAKCD\n", "EAUA0EGIAgDoIEQBAHQQogAAOghRAAAdhCgAgA5CFABAByEKAKCDEAUA0EGIAgDosHk1J9Van5Pk\n", "niTflOTvktyS5FiS+5Nc01obplYhAMAcOuGdqFrrWUlel+RNSUqS3UmuaK1dmuSBJFdOtUIAgDm0\n", "muG8a5P8SpK/H5//WGttcdx3W5JdU6oNAGBurRiiaq1fnaS01t49cf6jE6c8kuS8KdUGADC3TjQn\n", "aleSr6m1vjDJjiSvSvL+if7teXKoAgA4I6wY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rK\n", "wDPH7d1JrmitLdZar01yZZLbnuriqQzntdY+0Fr7tiSPZ/RHMUlemuS3x/1Hk/zXJDun8f5seD9Q\n", "a31XrXX3rAth7thyirX64lrrPbXWu2qtz551McyX1to1Sd6XJLXWrUkea60tjrtvS7JrpetP6k5U\n", "rfXzk/zsssMfaq1dfZzTz0vy3on20lYxnIGe6rOT5Dtba78xPufnaq0vX3ouGcSWU6zdc1trj9da\n", "vzrJG5JcNeuCmFvnJnl0ov1ITpBTTipEtdb+PMlqb5M+mmT7RPvTk/zFybw/G9cqPzu/l+TLkwhR\n", "LFn6f+Svx+3teXKogidprT0+/vquWuv2E53PGe1AnhyatufJoeqTnIrVeUtbv9yd5NVJUmv9lCSv\n", "TGJCKE9Sa31trfUzxs2vS3LvLOth7ixtObU0IfS4W05BktRad9Zarxh///z8Q/iGT9JaO5xka631\n", "gvGhq5LcudI1pyJEDUnSWnsgyR/VWv9XknuS/FRrzfbvLPd/kry51vr2JI+21vbMuB7miC2nWKP7\n", "klxVa92T5Pokr5ttOcyxpfnb1ya5ffw36Hmttd9e6SLbvgAAdPCwTQCADkIUAEAHIQoAoIMQBQDQ\n", "QYgCAOggRAEAdBCiAAA6CFEAAB2EKACADv8fn0xUCxJB1sMAAAAASUVORK5CYII=\n" ], "text/latex": [ "$\\mathcal{N}(\\mu=2, \\sigma=1),\\ N=1000$" ], "text/plain": [ "<__main__.Gaussian at 0x10665a4e0>" ] }, "execution_count": 4, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x = Gaussian(2.0, 1.0)\n", "x" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can also pass the object to the `display` function to display the default representation:" ] }, { "cell_type": "code", "execution_count": 5, "metadata": { "collapsed": false }, "outputs": [ { "data": { "image/png": [ "iVBORw0KGgoAAAANSUhEUgAAAlEAAAGLCAYAAADnMccKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\n", "AAALEgAACxIB0t1+/AAAGsJJREFUeJzt3X2QndddH/DvsUQ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377t0qX39roUZVgNMm+E8AIAOQhQA\n", "QAchCgCggxAFANBBiAIA6CBEAQB0EKIAADoIUQAAHYQoAIAOnlgOMGO2i4GNSYgCmDHbxcDGZDgP\n", "AKCDEAUA0EGIAgDoIEQBAHQwsRxgzmzbunnHHfc+tCexUg/mmRAFMGcOHD665cbxaj0r9WB+Gc4D\n", "AOggRAEAdBCiAAA6CFEAAB1MLAeYgcn98jadVXbMuBygwwlDVK310STvGTffmuT3k9yS5FiS+5Nc\n", "01obplYhwGlocr+863YtHJx1PcDareZO1N7W2uVLjVrrf0tyRWttsdZ6bZIrk9w2rQIBAObRakLU\n", "F9da70ny8STfnuSx1triuO+2JDdHiAIAzjCrmVj+3NbaS5K8LsmtSR6Z6HskyXlTqAsAYK6dMES1\n", "1h4ff31XkseTfNpE9/Ykj06nNACA+bViiKq17qy1XjH+/vlJ9ifZUmu9YHzKVUnunG6JAADz50Rz\n", "ou5L8sO11tdkdMfpmoyG726vtR5Lcl9rbfeUawQAmDsrhqjW2qEk37Ds8IeTXDK1igAANgBPLAcA\n", "6CBEAQB0sO0LwJRs27p5xx33PrQnSc4/5+x9Oy+68OrZVgSsJyEKYEoOHD665cbx1i7X71qYcTXA\n", "ejOcBwDQQYgCAOggRAEAdBCiAAA6mFgOcApMrtRLkk1nlR0zLAdYB0IUwCkwuVIvSa7btXBwlvUA\n", "J89wHgBAByEKAKCDEAUA0EGIAgDoYGI5wBxbvqrPHnwwP4QogDm2fFWfPfhgfhjOAwDoIEQBAHQQ\n", "ogAAOghRAAAdhCgAgA5CFABAByEKAKCDEAUA0EGIAgDo4InlABvU3gf337p46MjCUtuWMHBqCVEA\n", "G9TioSMLN9gSBmbGcB4AQAchCgCggxAFANBBiAIA6GBiOcAGsm3r5h133PvQniTZdFbZMeNy4Iwm\n", "RAFsIAcOH91y43hF3nW7Fg7Ouh44kxnOAwDoIEQBAHQQogAAOghRAAAdhCgAgA5CFABAByEKAKCD\n", "EAUA0EGIAgDoIEQBAHQQogAAOgh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tnderfUlSX43\n", "yZe21j48Pva9Sb4po/D2htbam6f1/mxMtdarM1qo8OHxoe9trb1ndhUxb2w5xVrUWh9NsvR/yFtb\n", "azfPsh7my/gJA29K8vbW2s211ouT3JLkWJL7k1zTWnvKyeNTCVG11s9O8m1J7k5Sxsd2JHlBa+1F\n", "tdbNSe6utb6ttfb306iBDWtI8uOttd+ddSHMn8ktp2qtn5rkzUkuPcFlnNn2ttYun3URzK2bMnrK\n", "wDPH7d1JrmitLdZar01yZZLbnuriqQzntdY+0Fr7tiSPZ/RHMUlemuS3x/1Hk/zXJDun8f5seD9Q\n", "a31XrXX3rAth7thyirX64lrrPbXWu2qtz551McyX1to1Sd6XJLXWrUkea60tjrtvS7JrpetP6k5U\n", "rfXzk/zsssMfaq1dfZzTz0vy3on20lYxnIGe6rOT5Dtba78xPufnaq0vX3ouGcSWU6zdc1trj9da\n", "vzrJG5JcNeuCmFvnJnl0ov1ITpBTTipEtdb+PMlqb5M+mmT7RPvTk/zFybw/G9cqPzu/l+TLkwhR\n", "LFn6f+Svx+3teXKogidprT0+/vquWuv2E53PGe1AnhyatufJoeqTnIrVeUtbv9yd5NVJUmv9lCSv\n", "TGJCKE9Sa31trfUzxs2vS3LvLOth7ixtObU0IfS4W05BktRad9Zarxh///z8Q/iGT9JaO5xka631\n", "gvGhq5LcudI1pyJEDUnSWnsgyR/VWv9XknuS/FRrzfbvLPd/kry51vr2JI+21vbMuB7miC2nWKP7\n", "klxVa92T5Pokr5ttOcyxpfnb1ya5ffw36Hmttd9e6SLbvgAAdPCwTQCADkIUAEAHIQoAoIMQBQDQ\n", "QYgCAOggRAEAdBCiAAA6CFEAAB2EKACADv8fn0xUCxJB1sMAAAAASUVORK5CYII=\n" ], "text/latex": [ "$\\mathcal{N}(\\mu=2, \\sigma=1),\\ N=1000$" ], "text/plain": [ "<__main__.Gaussian at 0x10665a4e0>" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "display(x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Use `display_png` to view the PNG representation:" ] }, { "cell_type": "code", "execution_count": 6, "metadata": { "collapsed": false }, "outputs": [ { "data": { "image/png": [ "iVBORw0KGgoAAAANSUhEUgAAAlEAAAGLCAYAAADnMccKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\n", "AAALEgAACxIB0t1+/AAAGsJJREFUeJzt3X2QndddH/DvsUQs5cXIRoCNA9mGGIR5Dy9KiBMnMmnq\n", "BAbamjOdYIOBafEMGd4MocEGUrAbG1Sgw7sLwWAI5bhT6tC0abCN4rQlSjEhmVAbG1yRRHgTYgsp\n", "xEKOlKd/3LvmeiOvdo/26t6VPp9/ds9znufe32rvaL/znHOeU4ZhCAAAa3PWrAsAANiIhCgAgA5C\n", "FABAByEKAKCDEAUA0EGIAgDoIEQBAHQQogAAOghRsIGVUraMv5ZSyq5Z1zMPSinnllK+atZ1AKc/\n", "IQo2oFLKV5ZS3pPkQClla5IfTPIXp+i9P7eUclMp5d+XUv6glPIVp+J9n6KWraWUXy6lvHjp2DAM\n", "B5K8opTyvFnVtRrHq32i77NLKb9SSvmuUsqvllIWTrYPWH9CFMypUsofl1JecZzjm5Jcn+Tnkrwo\n", "yRcleWwYhvefgprOSnJtktcNw/A9SX4zydtKKdun/d7HqeU7k7w+yRVJyrLun0zyE6e6ptU6Qe1J\n", "cluS24Zh+IUkv5rkd9ahD1hnQhTMoXEo+fKM/sgu97IkvzgMw68Ow/AnSb4/ya+fotIuSvI1ST5r\n", "3P6dJM9I8o2n6P2fMAzDrwzD8ENJPnqcvseT3F9KedFaX7eUcnYp5UdKKftLKfeVUspE36tLKfeX\n", "Un6/lPJPp1F7KeXzknzpMAz/c3zuO5N8finlczr7ntNbJ7AyIQrm08VJfiPJPy+lPG1Z38uS/GGS\n", "lFLOS/IpwzB87BTV9XdJnp3kgiQZhuHo+Ni5p+j91+ItSV691ouGYTiS0Z2s25JcmImAOAzDm5L8\n", "xjAMXz8Mw++tV6HLfEmSDyw79sGM7jr29H3NFG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DwDY\n", "CNaaW9yJAgDoIEQBAHQQogAAOghRAAAdhCgAgA5CFABAByEKAKCDEAUA0EGIAgDoIEQBAHQQogAA\n", "OghRAAAdhCgAgA5CFABAByEKAKCDEAUA0EGIAgDoIEQBAHQQogAAOghRAAAdhCgAgA6bZ10AwOli\n", "74P7b108dGRhqX3+OWfv23nRhVfPriJgmoQogHWyeOjIwg1377t0qX39roUZVgNMm+E8AIAOQhQA\n", "QAchCgCggxAFANBBiAIA6CBEAQB0EKIAADoIUQAAHYQoAIAOnlgOMGO2i4GNSYgCmDHbxcDGZDgP\n", "AKCDEAUA0EGIAgDoIEQBAHQwsRxgzmzbunnHHfc+tCexUg/mmRAFMGcOHD665cbxaj0r9WB+Gc4D\n", "AOggRAEAdBCiAAA6CFEAAB1MLAeYgcn98jadVXbMuBygwwlDVK310STvGTffmuT3k9yS5FiS+5Nc\n", "01obplYhwGlocr+863YtHJx1PcDareZO1N7W2uVLjVrrf0tyRWttsdZ6bZIrk9w2rQIBAObRakLU\n", "F9da70ny8STfnuSx1triuO+2JDdHiAIAzjCrmVj+3NbaS5K8LsmtSR6Z6HskyXlTqAsAYK6dMES1\n", "1h4ff31XkseTfNpE9/Ykj06nNACA+bViiKq17qy1XjH+/vlJ9ifZUmu9YHzKVUnunG6JAADz50Rz\n", "ou5L8sO11tdkdMfpmoyG726vtR5Lcl9rbfeUawQAmDsrhqjW2qEk37Ds8IeTXDK1igAANgBPLAcA\n", "6CBEAQB0sO0LwJRs27p5xx33PrQnSc4/5+x9Oy+68OrZVgSsJyEKYEoOHD665cbx1i7X71qYcTXA\n", "ejOcBwDQQYgCAOggRAEAdBCiAAA6mFgOcApMrtRLkk1nlR0zLAdYB0IUwCkwuVIvSa7btXBwlvUA\n", "J89wHgBAByEKAKCDEAUA0EGIAgDoYGI5wBxbvqrPHnwwP4QogDm2fFWfPfhgfhjOAwDoIEQBAHQQ\n", "ogAAOghRAAAdhCgAgA5CFABAByEKAKCDEAUA0EGIAgDo4InlABvU3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cN55SR6ZaH9kfOyvTroiYK699LnnPvZZ55z90SR53qc9/WkPHzoy65IAZqIMw7Dmi2qt\n", "NyV5U2vtveP2Lya5qbX2/snz7rrrrrW/OADAjFx22WVltef23om6K8k3J3lvrXVbkouXB6i1FgIA\n", "sJF0zYlqrf1BktRa35HkLUl+cD2LAgCYd13DeQAAZzp75wEAdBCiAAA6CFEAAB2mtnderfUlSX43\n", "yZe21j48Pva9Sb4po/D2htbam6f1/mxMtdarM1qo8OHxoe9trb1ndhUxb2w5xVrUWh9NsvR/yFtb\n", "azfPsh7my/gJA29K8vbW2s211ouT3JLkWJL7k1zTWnvKyeNTCVG11s9O8m1J7k5Sxsd2JHlBa+1F\n", "tdbNSe6utb6ttfb306iBDWtI8uOttd+ddSHMn8ktp2qtn5rkzUkuPcFlnNn2ttYun3URzK2bMnrK\n", "wDPH7d1JrmitLdZar01yZZLbnuriqQzntdY+0Fr7tiSPZ/RHMUlemuS3x/1Hk/zXJDun8f5seD9Q\n", "a31XrXX3rAth7thyirX64lrrPbXWu2qtz551McyX1to1Sd6XJLXWrUkea60tjrtvS7JrpetP6k5U\n", "rfXzk/zsssMfaq1dfZzTz0vy3on20lYxnIGe6rOT5Dtba78xPufnaq0vX3ouGcSWU6zdc1trj9da\n", "vzrJG5JcNeuCmFvnJnl0ov1ITpBTTipEtdb+PMlqb5M+mmT7RPvTk/zFybw/G9cqPzu/l+TLkwhR\n", "LFn6f+Svx+3teXKogidprT0+/vquWuv2E53PGe1AnhyatufJoeqTnIrVeUtbv9yd5NVJUmv9lCSv\n", "TGJCKE9Sa31trfUzxs2vS3LvLOth7ixtObU0IfS4W05BktRad9Zarxh///z8Q/iGT9JaO5xka631\n", "gvGhq5LcudI1pyJEDUnSWnsgyR/VWv9XknuS/FRrzfbvLPd/kry51vr2JI+21vbMuB7miC2nWKP7\n", "klxVa92T5Pokr5ttOcyxpfnb1ya5ffw36Hmttd9e6SLbvgAAdPCwTQCADkIUAEAHIQoAoIMQBQDQ\n", "QYgCAOggRAEAdBCiAAA6CFEAAB2EKACADv8fn0xUCxJB1sMAAAAASUVORK5CYII=\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "display_png(x)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "
\n", "It is important to note a subtle different between display and display_png. The former computes all representations of the object, and lets the notebook UI decide which to display. The later only computes the PNG representation.\n", "
" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Create a new Gaussian with different parameters:" ] }, { "cell_type": "code", "execution_count": 7, "metadata": { "collapsed": false }, "outputs": [ { "data": { "image/png": [ "iVBORw0KGgoAAAANSUhEUgAAAlYAAAGLCAYAAAAF7dxzAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\n", "AAALEgAACxIB0t1+/AAAG4FJREFUeJzt3X+U5lddH/D3d3chu0LiJi64MQhTMLrGqlXEBAmuTEAK\n", "2FbbeE8PJHaptU2PHEUieDiJP6qbkkD80UqhUquLgVBveqqhcsrRZN2EenRtI8gBE7M2XYGVCWV3\n", "3QWyzpLNt388z8TJMDObmb3zzDwzr9c5c3a+3/v9Ps8nz+7OvnPv/d7b9X0fAADO3abVLgAAYL0Q\n", "rAAAGhGsAAAaEawAABoRrAAAGhGsAAAaEawAABoRrAAAGhGsYJ3pum7r8Neu67rJ1a5nLei67sKu\n", "616w2nUA659gBetE13Xf1nXdnyY53nXdtiRvTPIXI3rvr+667le6rvvhrut+teu6iVG87zx1PK/r\n", "upu7rvt3Xdf9Xtd1z0+Svu+PJ3l513Vfsxp1PRkL1T6rfcHPeLltwAro+96XL19j8pXkfyd5+Tzn\n", "Nyf57ST/Ism3JnlBkteNsK4DSa4cfn9Fkj9chc9mU5J3JOmGx9cmOZpkx/D4qUnet9q/h8up/Wyf\n", "8XLbfPny1f5LjxWMia7rdiT5liRXz9P8kiTv6Pv+V/u+/5Mkb0jy6yOq62uTfHPf9/8zSfq+/6Mk\n", "X9d13XNG8f6zXJrkO5J81fD4fUmeluR7h3WdTvJA13UvWuoLd113X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q3XJflYkpRS\n", "tiV5pNY6NWy+LcnkYvc377EqpXxdkl+ac/rhWuueeS6/KMlHZx3PbIPDBrTQn50k/6rW+u7hNb9c\n", "SnnZzLppENtpsXTPrbWeLqV8e5K3JLl2tQtizbowybFZx0dzlpzSPFjVWv88yZPtYj2WZMes42ck\n", "+YvWNTEenuSfnd9K8i1JBCtmzPwc+avh8Y48MWjBE9RaTw9//eNSyo6zXc+GdjxPDFI78sSg9SVW\n", "66nAmW1t9id5dZKUUp6S5JVJTDrlCUopbyqlPHN4+D1J7lvNelhzZrbTmpl0Ou92WpAkpZTLSylX\n", "D7//1vxtIIcvUWs9lWRbKeXi4alrk9y12D2rFaz6JKm1PpjkD0spf5Dk3iRvq7VOr1JNrF3/K8n7\n", "Syn3JDlWaz2wyvWwhthOiyW6P8m1pZQDSW5M8ubVLYc1bGY++PVJ7hj+G/Q1tdb3LnaTLW0AABqx\n", "QCgAQCOCFQBAI4IVAEAjghUAQCOCFQBAI4IVAEAjghUAQCOCFQBAI4IVAEAj/x8Ld0kx4zM3zgAA\n", "AABJRU5ErkJggg==\n" ], "text/latex": [ "$\\mathcal{N}(\\mu=0, \\sigma=2),\\ N=2000$" ], "text/plain": [ "<__main__.Gaussian at 0x106ab8c18>" ] }, "execution_count": 7, "metadata": {}, "output_type": "execute_result" } ], "source": [ "x2 = Gaussian(0, 2, 2000)\n", "x2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can then compare the two Gaussians by displaying their histograms:" ] }, { "cell_type": "code", "execution_count": 8, "metadata": { "collapsed": false }, "outputs": [ { "data": { "image/png": [ "iVBORw0KGgoAAAANSUhEUgAAAlEAAAGLCAYAAADnMccKAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\n", "AAALEgAACxIB0t1+/AAAGsJJREFUeJzt3X2QndddH/DvsUQs5cXIRoCNA9mGGIR5Dy9KiBMnMmnq\n", "BAbamjOdYIOBafEMGd4MocEGUrAbG1Sgw7sLwWAI5bhT6tC0abCN4rQlS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CmDHbxcDGZDgP\n", "AKCDEAUA0EGIAgDoIEQBAHQwsRxgzmzbunnHHfc+tCexUg/mmRAFMGcOHD665cbxaj0r9WB+Gc4D\n", "AOggRAEAdBCiAAA6CFEAAB1MLAeYgcn98jadVXbMuBygwwlDVK310STvGTffmuT3k9yS5FiS+5Nc\n", "01obplYhwGlocr+863YtHJx1PcDareZO1N7W2uVLjVrrf0tyRWttsdZ6bZIrk9w2rQIBAObRakLU\n", "F9da70ny8STfnuSx1triuO+2JDdHiAIAzjCrmVj+3NbaS5K8LsmtSR6Z6HskyXlTqAsAYK6dMES1\n", "1h4ff31XkseTfNpE9/Ykj06nNACA+bViiKq17qy1XjH+/vlJ9ifZUmu9YHzKVUnunG6JAADz50Rz\n", "ou5L8sO11tdkdMfpmoyG726vtR5Lcl9rbfeUawQAmDsrhqjW2qEk37Ds8IeTXDK1igAANgBPLAcA\n", "6CBEAQB0sO0LwJRs27p5xx33PrQnSc4/5+x9Oy+68OrZVgSsJyEKYEoOHD665cbx1i7X71qYcTXA\n", "ejOcBwDQQYgCAOggRAEAdBCiAAA6mFgOcApMrtRLkk1nlR0zLAdYB0IUwCkwuVIvSa7btXBwlvUA\n", "J89wHgBAByEKAKCDEAUA0EGIAgDoYGI5wBxbvqrPHnwwP4QogDm2fFWfPfhgfhjOAwDoIEQBAHQQ\n", "ogAAOghRAAAdhCgAgA5CFABAByEKAKCDEAUA0EGIAgDo4InlABvU3gf337p46MjCUtuWMHBqCVEA\n", "G9TioSMLN9gSBmbGcB4AQAchCgCggxAFANBBiAIA6GBiOcAGsm3r5h133PvQniTZdFbZMeNy4Iwm\n", "RAFsIAcOH91y43hF3nW7Fg7Ouh44kxnOAwDoIEQBAHQQogAAOghRAAAdhCgAgA5CFABAByEKAKCD\n", "EAUA0EGIAgDoIEQBAHQQogAAOghRAAAdhCgAgA5CFABAByEKAKCDEAUA0EGIAgDosHk1J9Van5Pk\n", "niTflOTvktyS5FiS+5Nc01obplYhAMAcOuGdqFrrWUl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fPsh7my/gJA29K8vbW2s211ouT3JLkWJL7k1zTWnvKyeNTCVG11s9O8m1J7k5Sxsd2JHlBa+1F\n", "tdbNSe6utb6ttfb306iBDWtI8uOttd+ddSHMn8ktp2qtn5rkzUkuPcFlnNn2ttYun3URzK2bMnrK\n", "wDPH7d1JrmitLdZar01yZZLbnuriqQzntdY+0Fr7tiSPZ/RHMUlemuS3x/1Hk/zXJDun8f5seD9Q\n", "a31XrXX3rAth7thyirX64lrrPbXWu2qtz551McyX1to1Sd6XJLXWrUkea60tjrtvS7JrpetP6k5U\n", "rfXzk/zsssMfaq1dfZzTz0vy3on20lYxnIGe6rOT5Dtba78xPufnaq0vX3ouGcSWU6zdc1trj9da\n", "vzrJG5JcNeuCmFvnJnl0ov1ITpBTTipEtdb+PMlqb5M+mmT7RPvTk/zFybw/G9cqPzu/l+TLkwhR\n", "LFn6f+Svx+3teXKogidprT0+/vquWuv2E53PGe1AnhyatufJoeqTnIrVeUtbv9yd5NVJUmv9lCSv\n", "TGJCKE9Sa31trfUzxs2vS3LvLOth7ixtObU0IfS4W05BktRad9Zarxh///z8Q/iGT9JaO5xka631\n", "gvGhq5LcudI1pyJEDUnSWnsgyR/VWv9XknuS/FRrzfbvLPd/kry51vr2JI+21vbMuB7miC2nWKP7\n", "klxVa92T5Pokr5ttOcyxpfnb1ya5ffw36Hmttd9e6SLbvgAAdPCwTQCADkIUAEAHIQoAoIMQBQDQ\n", "QYgCAOggRAEAdBCiAAA6CFEAAB2EKACADv8fn0xUCxJB1sMAAAAASUVORK5CYII=\n" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "image/png": [ "iVBORw0KGgoAAAANSUhEUgAAAlYAAAGLCAYAAAAF7dxzAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\n", "AAALEgAACxIB0t1+/AAAG4FJREFUeJzt3X+U5lddH/D3d3chu0LiJi64MQhTMLrGqlXEBAmuTEAK\n", "2FbbeE8PJHaptU2PHEUieDiJP6qbkkD80UqhUquLgVB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AjghUAQCOCFQBAI4IVAEAjghUAQCOCFQBAI4IVAEAj/x8Ld0kx4zM3zgAA\n", "AABJRU5ErkJggg==\n" ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "display_png(x)\n", "display_png(x2)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Note that like `print`, you can call any of the `display` functions multiple times in a cell." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## Adding IPython display support to existing objects" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "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. We now illustrate how to add rich output capabilities to existing objects. We will use the NumPy polynomials and change their default representation to be a formatted LaTeX expression." ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "First, consider how a NumPy polynomial object renders by default:" ] }, { "cell_type": "code", "execution_count": 9, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "Polynomial([ 1., 2., 3.], [-10., 10.], [-1, 1])" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p = np.polynomial.Polynomial([1,2,3], [-10, 10])\n", "p" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Next, define a function that pretty-prints a polynomial as a LaTeX string:" ] }, { "cell_type": "code", "execution_count": 10, "metadata": { "collapsed": false }, "outputs": [], "source": [ "def poly_to_latex(p):\n", " terms = ['%.2g' % p.coef[0]]\n", " if len(p) > 1:\n", " term = 'x'\n", " c = p.coef[1]\n", " if c!=1:\n", " term = ('%.2g ' % c) + term\n", " terms.append(term)\n", " if len(p) > 2:\n", " for i in range(2, len(p)):\n", " term = 'x^%d' % i\n", " c = p.coef[i]\n", " if c!=1:\n", " term = ('%.2g ' % c) + term\n", " terms.append(term)\n", " px = '$P(x)=%s$' % '+'.join(terms)\n", " dom = r', $x \\in [%.2g,\\ %.2g]$' % tuple(p.domain)\n", " return px+dom" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "This produces, on our polynomial ``p``, the following:" ] }, { "cell_type": "code", "execution_count": 11, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/plain": [ "'$P(x)=1+2 x+3 x^2$, $x \\\\in [-10,\\\\ 10]$'" ] }, "execution_count": 11, "metadata": {}, "output_type": "execute_result" } ], "source": [ "poly_to_latex(p)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "You can render this string using the `Latex` class:" ] }, { "cell_type": "code", "execution_count": 12, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$P(x)=1+2 x+3 x^2$, $x \\in [-10,\\ 10]$" ], "text/plain": [ "" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "from IPython.display import Latex\n", "Latex(poly_to_latex(p))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "However, you can configure IPython to do this automatically by registering the `Polynomial` class and the `poly_to_latex` function with an IPython display formatter. Let's look at the default formatters provided by IPython:" ] }, { "cell_type": "code", "execution_count": 13, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ " image/png : PNGFormatter\n", " application/pdf : PDFFormatter\n", " text/html : HTMLFormatter\n", " image/jpeg : JPEGFormatter\n", " text/plain : PlainTextFormatter\n", " text/markdown : MarkdownFormatter\n", " application/json : JSONFormatter\n", " application/javascript : JavascriptFormatter\n", " text/latex : LatexFormatter\n", " image/svg+xml : SVGFormatter\n" ] } ], "source": [ "ip = get_ipython()\n", "for mime, formatter in ip.display_formatter.formatters.items():\n", " print('%24s : %s' % (mime, formatter.__class__.__name__))" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The `formatters` attribute is a dictionary keyed by MIME types. To define a custom LaTeX display function, you want a handle on the `text/latex` formatter:" ] }, { "cell_type": "code", "execution_count": 14, "metadata": { "collapsed": false }, "outputs": [], "source": [ "ip = get_ipython()\n", "latex_f = ip.display_formatter.formatters['text/latex']" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "The formatter object has a couple of methods for registering custom display functions for existing types." ] }, { "cell_type": "code", "execution_count": 15, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Help on method for_type in module IPython.core.formatters:\n", "\n", "for_type(typ, func=None) method of IPython.core.formatters.LatexFormatter instance\n", " Add a format function for a given type.\n", " \n", " Parameters\n", " -----------\n", " typ : type or '__module__.__name__' string for a type\n", " The class of the object that will be formatted using `func`.\n", " func : callable\n", " A callable for computing the format data.\n", " `func` will be called with the object to be formatted,\n", " and will return the raw data in this formatter's format.\n", " Subclasses may use a different call signature for the\n", " `func` argument.\n", " \n", " If `func` is None or not specified, there will be no change,\n", " only returning the current value.\n", " \n", " Returns\n", " -------\n", " oldfunc : callable\n", " The currently registered callable.\n", " If you are registering a new formatter,\n", " this will be the previous value (to enable restoring later).\n", "\n" ] } ], "source": [ "help(latex_f.for_type)" ] }, { "cell_type": "code", "execution_count": 16, "metadata": { "collapsed": false }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "Help on method for_type_by_name in module IPython.core.formatters:\n", "\n", "for_type_by_name(type_module, type_name, func=None) method of IPython.core.formatters.LatexFormatter instance\n", " Add a format function for a type specified by the full dotted\n", " module and name of the type, rather than the type of the object.\n", " \n", " Parameters\n", " ----------\n", " type_module : str\n", " The full dotted name of the module the type is defined in, like\n", " ``numpy``.\n", " type_name : str\n", " The name of the type (the class name), like ``dtype``\n", " func : callable\n", " A callable for computing the format data.\n", " `func` will be called with the object to be formatted,\n", " and will return the raw data in this formatter's format.\n", " Subclasses may use a different call signature for the\n", " `func` argument.\n", " \n", " If `func` is None or unspecified, there will be no change,\n", " only returning the current value.\n", " \n", " Returns\n", " -------\n", " oldfunc : callable\n", " The currently registered callable.\n", " If you are registering a new formatter,\n", " this will be the previous value (to enable restoring later).\n", "\n" ] } ], "source": [ "help(latex_f.for_type_by_name)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "In this case, we will use `for_type_by_name` to register `poly_to_latex` as the display function for the `Polynomial` type:" ] }, { "cell_type": "code", "execution_count": 17, "metadata": { "collapsed": false }, "outputs": [], "source": [ "latex_f.for_type_by_name('numpy.polynomial.polynomial',\n", " 'Polynomial', poly_to_latex)" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Once the custom display function has been registered, all NumPy `Polynomial` instances will be represented by their LaTeX form instead:" ] }, { "cell_type": "code", "execution_count": 18, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$P(x)=1+2 x+3 x^2$, $x \\in [-10,\\ 10]$" ], "text/plain": [ "Polynomial([ 1., 2., 3.], [-10., 10.], [-1, 1])" ] }, "execution_count": 18, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p" ] }, { "cell_type": "code", "execution_count": 19, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/latex": [ "$P(x)=-20+71 x+-15 x^2+x^3$, $x \\in [-1,\\ 1]$" ], "text/plain": [ "Polynomial([-20., 71., -15., 1.], [-1, 1], [-1, 1])" ] }, "execution_count": 19, "metadata": {}, "output_type": "execute_result" } ], "source": [ "p2 = np.polynomial.Polynomial([-20, 71, -15, 1])\n", "p2" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## More complex display with `_ipython_display_`" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "Rich output special methods and functions can only display one object or MIME type at a time. Sometimes this is not enough if you want to display multiple objects or MIME types at once. An example of this would be to use an HTML representation to put some HTML elements in the DOM and then use a JavaScript representation to add events to those elements.\n", "\n", "**IPython 2.0** recognizes another display method, `_ipython_display_`, which allows your objects to take complete control of displaying themselves. If this method is defined, IPython will call it, and make no effort to display the object using the above described `_repr_*_` methods for custom display functions. It's a way for you to say \"Back off, IPython, I can display this myself.\" Most importantly, your `_ipython_display_` method can make multiple calls to the top-level `display` functions to accomplish its goals.\n", "\n", "Here is an object that uses `display_html` and `display_javascript` to make a plot using the [Flot](http://www.flotcharts.org/) JavaScript plotting library:" ] }, { "cell_type": "code", "execution_count": 20, "metadata": { "collapsed": false }, "outputs": [], "source": [ "import json\n", "import uuid\n", "from IPython.display import display_javascript, display_html, display\n", "\n", "class FlotPlot(object):\n", " def __init__(self, x, y):\n", " self.x = x\n", " self.y = y\n", " self.uuid = str(uuid.uuid4())\n", " \n", " def _ipython_display_(self):\n", " json_data = json.dumps(list(zip(self.x, self.y)))\n", " display_html('
'.format(self.uuid),\n", " raw=True\n", " )\n", " display_javascript(\"\"\"\n", " require([\"//cdnjs.cloudflare.com/ajax/libs/flot/0.8.2/jquery.flot.min.js\"], function() {\n", " var line = JSON.parse(\"%s\");\n", " console.log(line);\n", " $.plot(\"#%s\", [line]);\n", " });\n", " \"\"\" % (json_data, self.uuid), raw=True)\n" ] }, { "cell_type": "code", "execution_count": 21, "metadata": { "collapsed": false }, "outputs": [ { "data": { "text/html": [ "
" ] }, "metadata": {}, "output_type": "display_data" }, { "data": { "application/javascript": [ "\n", " require([\"//cdnjs.cloudflare.com/ajax/libs/flot/0.8.2/jquery.flot.min.js\"], function() {\n", " var line = JSON.parse(\"[[0.0, 0.0], [0.20408163265306123, 0.20266793654820095], [0.40816326530612246, 0.39692414892492234], [0.6122448979591837, 0.5747060412161791], [0.8163265306122449, 0.7286347834693503], [1.0204081632653061, 0.8523215697196184], [1.2244897959183674, 0.9406327851124867], [1.4285714285714286, 0.9899030763721239], [1.6326530612244898, 0.9980874821347183], [1.836734693877551, 0.9648463089837632], [2.0408163265306123, 0.8915592304110037], [2.2448979591836737, 0.7812680235262639], [2.4489795918367347, 0.6385503202266021], [2.6530612244897958, 0.469329612777201], [2.857142857142857, 0.28062939951435684], [3.0612244897959187, 0.0802816748428135], [3.2653061224489797, -0.12339813736217871], [3.4693877551020407, -0.3219563150726187], [3.673469387755102, -0.5071517094845144], [3.8775510204081636, -0.6712977935519321], [4.081632653061225, -0.8075816909683364], [4.285714285714286, -0.9103469443107828], [4.4897959183673475, -0.9753282860670456], [4.6938775510204085, -0.9998286683840896], [4.8979591836734695, -0.9828312039256306], [5.1020408163265305, -0.9250413717382029], [5.3061224489795915, -0.8288577363730427], [5.510204081632653, -0.6982723955653996], [5.714285714285714, -0.5387052883861563], [5.918367346938775, -0.35677924089893803], [6.122448979591837, -0.16004508604325057], [6.326530612244898, 0.04333173336868346], [6.530612244897959, 0.2449100710119793], [6.73469387755102, 0.4363234264718193], [6.938775510204081, 0.6096271964908323], [7.142857142857143, 0.7576284153927202], [7.346938775510204, 0.8741842988197335], [7.551020408163265, 0.9544571997387519], [7.755102040816327, 0.9951153947776636], [7.959183673469388, 0.9944713672636168], [8.16326530612245, 0.9525518475314604], [8.36734693877551, 0.8710967034823207], [8.571428571428571, 0.7534867274396376], [8.775510204081632, 0.6046033165061543], [8.979591836734695, 0.43062587038273736], [9.183673469387756, 0.23877531564403087], [9.387755102040817, 0.03701440148506237], [9.591836734693878, -0.1662827938487564], [9.795918367346939, -0.3626784288265488], [10.0, -0.5440211108893699]]\");\n", " console.log(line);\n", " $.plot(\"#4ad544ff-a161-4493-ba2c-f99531e317bd\", [line]);\n", " });\n", " " ] }, "metadata": {}, "output_type": "display_data" } ], "source": [ "import numpy as np\n", "x = np.linspace(0,10)\n", "y = np.sin(x)\n", "FlotPlot(x, np.sin(x))" ] } ], "metadata": { "kernelspec": { "display_name": "Python 3", "language": "python", "name": "python3" }, "language_info": { "codemirror_mode": { "name": "ipython", "version": 3 }, "file_extension": ".py", "mimetype": "text/x-python", "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", "version": "3.4.2" } }, "nbformat": 4, "nbformat_minor": 0 }