##// END OF EJS Templates
Adding clear_output to kernel and HTML notebook.
Adding clear_output to kernel and HTML notebook.

File last commit:

r5080:bdf1ecd4
r5080:bdf1ecd4
Show More
clear_output.ipynb
55 lines | 2.1 KiB | text/plain | TextLexer
Brian Granger
Adding clear_output to kernel and HTML notebook.
r5080 {
"worksheets": [
{
"cells": [
{
"source": "A demonstration of the ability to clear the output of a cell during execution.",
"cell_type": "markdown"
},
{
"cell_type": "code",
"language": "python",
"outputs": [],
"collapsed": true,
"prompt_number": 8,
"input": "from IPython.core.display import clear_output, display"
},
{
"cell_type": "code",
"language": "python",
"outputs": [],
"collapsed": false,
"prompt_number": 4,
"input": "import time"
},
{
"source": "First we show how this works with ``display``:",
"cell_type": "markdown"
},
{
"cell_type": "code",
"language": "python",
"outputs": [],
"collapsed": false,
"prompt_number": 17,
"input": "for i in range(10):\n display(\"Time step: %i\" % i)\n time.sleep(0.5)\n clear_output()"
},
{
"source": "Next, we show that ``clear_output`` can also be used to create a primitive form of animation using\nmatplotlib:",
"cell_type": "markdown"
},
{
"cell_type": "code",
"language": "python",
"outputs": [],
"collapsed": false,
"prompt_number": 20,
"input": "for i in range(10):\n figure()\n plot(rand(100))\n show()\n time.sleep(0.1)\n clear_output()"
}
]
}
],
"metadata": {
"name": "clear_output"
},
"nbformat": 2
}