--- title: NumPy and Matplotlib examples keywords: fastai sidebar: home_sidebar nb_path: "venv/Lib/site-packages/nbconvert/tests/files/notebook2.ipynb" ---
{% raw %}
{% endraw %}

First import NumPy and Matplotlib:

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

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

{% raw %}
a = np.random.uniform(size=(100,100))
{% endraw %} {% raw %}
a.shape
(100, 100)
{% endraw %} {% raw %}
evs = np.linalg.eigvals(a)
{% endraw %} {% raw %}
evs.shape
(100,)
{% endraw %}

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:

{% raw %}
plt.hist(evs.real)
(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>)
{% endraw %}
import math 
import numpy as np
def matrix_calc(L=None):
    """docstring"""
    if L is None:       L = np.random.random(size=(1,1))    raise Exception("message")

This string contains a strikethrough, struckthrough.

This string contains a ' single tick inside backticks, leading to a \textquotesingle in latex.