-
Notifications
You must be signed in to change notification settings - Fork 1
/
ipython_presentation_resources.html
67 lines (58 loc) · 2.81 KB
/
ipython_presentation_resources.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
---
layout: post
title: Resources for IPython presentations
---
<p>
A list of useful IPython tools I've made/compiled from other people that I use in my IPython presentations.
<h3>Formatted tables</h3>
<ul>
<li><a href="http://melissagymrek.com/python/2014/01/11/ipython-tables.html">Formatted tables in IPython</a></li>
<li><a href="https://github.com/epmoyer/ipy_table/">ipy_table library</a></li>
</ul>
<h3>Widgets for animated slides</h3>
For these I have forked the <a href="https://github.com/jakevdp/ipywidgets">ipywidgets</a> github repository and added my own useful widgets for animation.
<ul>
<li><a href="http://melissagymrek.com/python/2013/12/12/ipython-presentations-build-figures.html">Adding animated figures to IPython presentations</a></li>
<li><a href="http://melissagymrek.com/python/2014/01/12/ipython-presentations-build-tables.html">Adding
animated tables to IPython presentations</a></li>
</ul>
<h3>Templates</h3>
For many presentations, you may not want the code from input cells to
be visible. I use the <a href="http://www.damian.oquanta.info/posts/hide-the-input-cells-from-your-ipython-slides.html">template posted on @damian_vila's
blog</a>. This
allows you to hide the input slides, but clicking on the output cell
toggles the input cell. This makes it really fun in presentations, if
someone asks how you did something, simply click on the figure/table
to reveal the code!
To use a template to compile your slides:
<ul>
<li>Create a directory where you will store your templates</li>
<li>Add this directory to the list:
{% highlight python %}c.HTMLExporter.template_path{% endhighlight %}
in ~.ipython/profile_default/ipython_nbconvert_config.py</li>
<li>Use the template when compiling your slides. If you named the
tamplate my_template.tpl, and stored it in a directory listed in the
list below, you can do:
{% highlight python %}
ipython nbconvert my_slides.ipynb --to slides --template my_template
{% endhighlight %}</li>
</ul>
<a href="http://ipython.org/ipython-doc/stable/config/overview.html">Read more about IPython configuration</a>
<h3>Other useful functions</h3>
<h4>Center a figure</h4>
{% highlight python %}
import matplotlib.pyplot
import rpy2.robjects
import IPython.core.display
from IPython import get_ipython
def center_figure(fig):
ip = get_ipython()
png_rep = ip.display_formatter.formatters["image/png"](fig)
matplotlib.pyplot.close(fig)
return IPython.core.display.HTML('<center><img src="data:Image/png;base64,{0}"></center>'.format(png_rep.encode('base64')))
{% endhighlight %}
<h3>Example</h3>
Here's an example <a href="example-slideshow.slides.html">slideshow</a> showing these features, and
the <a href="https://github.com/mgymrek/mgymrek.github.io/blob/master/example-slideshow.ipynb">ipynb
file</a> used to generate it (make sure the "Cell Toolbar" is set to
"Slideshow").