##// END OF EJS Templates
Merge pull request #6828 from takluyver/terminal-list...
Merge pull request #6828 from takluyver/terminal-list Add terminals tab to the dashboard

File last commit:

r15387:80dcdc9e
r18615:96791286 merge
Show More
notebook2.ipynb
223 lines | 107.9 KiB | text/plain | TextLexer

NumPy and Matplotlib examples

First import NumPy and Matplotlib:

In [1]:
%matplotlib inline
import matplotlib
import matplotlib.pyplot as plt
print(matplotlib.backends.backend)
module://IPython.kernel.zmq.pylab.backend_inline
In [2]:
from IPython.display import set_matplotlib_formats
set_matplotlib_formats('png', 'pdf')
matplotlib.rcParams['figure.figsize'] = (2,1)
In [3]:
ip.display_formatter.formatters['application/pdf'].type_printers
Out[3]:
{matplotlib.figure.Figure: <function IPython.core.pylabtools.<lambda>>}
In [4]:
import numpy as np

Now we show some very basic examples of how they can be used.

In [5]:
a = np.random.uniform(size=(100,100))
In [6]:
a.shape
Out[6]:
(100, 100)
In [7]:
evs = np.linalg.eigvals(a)
In [8]:
evs.shape
Out[8]:
(100,)

Here is a very long heading that pandoc will wrap and wrap and wrap and wrap and wrap and wrap and wrap and wrap and wrap and wrap and wrap and wrap

Here is a cell that has both text and PNG output:

In [9]:
plt.hist(evs.real)
Out[9]:
(array([97,  2,  0,  0,  0,  0,  0,  0,  0,  1]),
 array([ -2.59479443,   2.67371141,   7.94221725,  13.21072308,
         18.47922892,  23.74773476,  29.0162406 ,  34.28474644,
         39.55325228,  44.82175812,  50.09026395]),
 <a list of 10 Patch objects>)
No description has been provided for this image
def foo(bar=1):
    """docstring"""
    raise Exception("message")