I have an ipython/jupyter notebook that I visualize using NBviewer.
How can I hide all the code from the notebook rendered by NBviewer, so that only the output of code (e.g. plots and tables) and the markdown cells are shown?
I have an ipython/jupyter notebook that I visualize using NBviewer.
How can I hide all the code from the notebook rendered by NBviewer, so that only the output of code (e.g. plots and tables) and the markdown cells are shown?
The newest IPython notebook version do not allow executing javascript in markdown cells anymore, so adding a new markdown cell with the following javascript code will not work anymore to hide your code cells (refer to this link)
Change ~/.ipython/profile_default/static/custom/custom.js as below:
Convert cell to Markdown and use HTML5
<details>
tag as in the example byjoyrexus
:https://gist.github.com/joyrexus/16041f2426450e73f5df9391f7f7ae5f
This will render an IPython notebook output. However, you will note be able to view the input code. You can copy a notebook, then add this code if needed to share with someone who does not need to view the code.
With all the solutions above even though you're hiding the code, you'll still get the
[<matplotlib.lines.Line2D at 0x128514278>]
crap above your figure which you probably don't want.If you actually want to get rid of the input rather than just hiding it, I think the cleanest solution is to save your figures to disk in hidden cells, and then just including the images in Markdown cells using e.g.
![Caption](figure1.png)
.Here is a nice article (the same one @Ken posted) on how to polish up Jpuyter (the new IPython) notebooks for presentation. There are countless ways to extend Jupyter using JS, HTML, and CSS, including the ability to communicate with the notebook's python kernel from javascript. There are magic decorators for
%%HTML
and%%javascript
so you can just do something like this in a cell by itself:I can also vouch Chris's methods work in jupyter 4.X.X.
For better display with printed document or a report, we need to remove the button as well, and the ability to show or hide certain code blocks. Here's what I use (simply copy-paste this to your first cell):
Then in your next cells:
and