#!/usr/bin/env python # coding: utf-8 # # Code Hiding on nbviewer # # When this notebook first loads on [nbviewer](http://nbviewer.jupyter.org/gist/parente/35f5d3a9145bd3f030c8), 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](https://gist.github.com/parente/4c3e6936d0d7a46fd071) 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](https://plot.ly/ipython-notebooks/) remains interactive on nbviewer as well. # In[1]: get_ipython().run_line_magic('matplotlib', 'inline') # In[2]: from plotly.offline import init_notebook_mode, iplot, iplot_mpl import matplotlib.pyplot as plt import numpy as np # In[3]: init_notebook_mode() # In[4]: 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 # In[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) # In[6]: get_ipython().run_cell_magic('html', '', '\n')