Code Hiding on nbviewer
April 08, 2016
When this notebook first loads on nbviewer, all of the input cells are hidden. To reveal them, click the element tag icon in the top right of nbviewer. Click it again to hide them once more.
The last code cell loads a CDN-hosted script to enable the show/hide interactivity. The script encapsulates the recipe from http://chris-said.io/2016/02/13/how-to-make-polished-jupyter-presentations-with-optional-code-visibility/.
It's cool, too, that the plot.ly example remains interactive on nbviewer as well.
%matplotlib inline
from plotly.offline import init_notebook_mode, iplot, iplot_mpl
import matplotlib.pyplot as plt
import numpy as np
init_notebook_mode()
n = 50
x, y, z, s, ew = np.random.rand(5, n)
c, ec = np.random.rand(2, n, 4)
area_scale, width_scale = 500, 5
fig, ax = plt.subplots()
sc = ax.scatter(x, y, c=c,
s=np.square(s)*area_scale,
edgecolor=ec,
linewidth=ew*width_scale)
ax.grid()
iplot_mpl(fig)
%%html
<script src="https://cdn.rawgit.com/parente/4c3e6936d0d7a46fd071/raw/65b816fb9bdd3c28b4ddf3af602bfd6015486383/code_toggle.js"></script>