Sample Notebook

This Jupyter Notebook is intended to be an example with some references. Jupyter uses Markdown Syntax and accept LaTeX and HTML codes.

With this, one can easily write bold or italic words. One can also type some code inline or code block like bellow:

import numpy
x = numpy.arange(10)
print x

One can write formulas using LaTeX syntax like $\cos \left( x \right) = \frac{X}{Y}$ or create numerated lists like:

  1. Item 1
  2. Item 2
  3. Item 3

Or unordered lists:

  • Item 1
  • Item 2
  • Item 3

This is a title in HTML

So you can edit your notebook by using HTML syntax also if you want.


Interactive Widgets


In [3]:
from ipywidgets.widgets import interact
from matplotlib import pyplot
from numpy import arange, sin, pi
t = arange(0, 1, 0.1)

def plot_sin(f):
    pyplot.plot(t, sin(2 * pi * f + t))
    pyplot.show()
    
interact(plot_sin, f=(1, 10, 0.1))


---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-3-ec7ba283f115> in <module>()
----> 1 get_ipython().magic(u'matplotlib notebook')
      2 from ipywidgets.widgets import interact
      3 from matplotlib import pyplot
      4 from numpy import arange, sin, pi
      5 t = arange(0, 1, 0.1)

/Users/Bruno/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in magic(self, arg_s)
   2161         magic_name, _, magic_arg_s = arg_s.partition(' ')
   2162         magic_name = magic_name.lstrip(prefilter.ESC_MAGIC)
-> 2163         return self.run_line_magic(magic_name, magic_arg_s)
   2164 
   2165     #-------------------------------------------------------------------------

/Users/Bruno/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in run_line_magic(self, magic_name, line)
   2082                 kwargs['local_ns'] = sys._getframe(stack_depth).f_locals
   2083             with self.builtin_trap:
-> 2084                 result = fn(*args,**kwargs)
   2085             return result
   2086 

<decorator-gen-106> in matplotlib(self, line)

/Users/Bruno/anaconda/lib/python2.7/site-packages/IPython/core/magic.pyc in <lambda>(f, *a, **k)
    191     # but it's overkill for just that one bit of state.
    192     def magic_deco(arg):
--> 193         call = lambda f, *a, **k: f(*a, **k)
    194 
    195         if callable(arg):

/Users/Bruno/anaconda/lib/python2.7/site-packages/IPython/core/magics/pylab.pyc in matplotlib(self, line)
     98             print("Available matplotlib backends: %s" % backends_list)
     99         else:
--> 100             gui, backend = self.shell.enable_matplotlib(args.gui)
    101             self._show_matplotlib_backend(args.gui, backend)
    102 

/Users/Bruno/anaconda/lib/python2.7/site-packages/IPython/core/interactiveshell.pyc in enable_matplotlib(self, gui)
   2949                 gui, backend = pt.find_gui_and_backend(self.pylab_gui_select)
   2950 
-> 2951         pt.activate_matplotlib(backend)
   2952         pt.configure_inline_support(self, backend)
   2953 

/Users/Bruno/anaconda/lib/python2.7/site-packages/IPython/core/pylabtools.pyc in activate_matplotlib(backend)
    293     matplotlib.rcParams['backend'] = backend
    294 
--> 295     import matplotlib.pyplot
    296     matplotlib.pyplot.switch_backend(backend)
    297 

/Users/Bruno/anaconda/lib/python2.7/site-packages/matplotlib/pyplot.py in <module>()
    112 
    113 from matplotlib.backends import pylab_setup
--> 114 _backend_mod, new_figure_manager, draw_if_interactive, _show = pylab_setup()
    115 
    116 _IP_REGISTERED = None

/Users/Bruno/anaconda/lib/python2.7/site-packages/matplotlib/backends/__init__.pyc in pylab_setup()
     30     # imports. 0 means only perform absolute imports.
     31     backend_mod = __import__(backend_name,
---> 32                              globals(),locals(),[backend_name],0)
     33 
     34     # Things we pull in from all backends

/Users/Bruno/anaconda/lib/python2.7/site-packages/matplotlib/backends/backend_macosx.py in <module>()
     22 
     23 import matplotlib
---> 24 from matplotlib.backends import _macosx
     25 
     26 

RuntimeError: Python is not installed as a framework. The Mac OS X backend will not be able to function correctly if Python is not installed as a framework. See the Python documentation for more information on installing Python as a framework on Mac OS X. Please either reinstall Python as a framework, or try one of the other backends. If you are Working with Matplotlib in a virtual enviroment see 'Working with Matplotlib in Virtual environments' in the Matplotlib FAQ

In [ ]: