This notebook is part of the IPython NB Example; the content is available on GitHub.Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.

Contents | IPynb Example 2 >

IPynb Example 1

Purpose: The purpose of this workbook is to help you get comfortable with the topics below.

Recomended Usage

  • Run each of the cells (Shift+Enter) and edit them as necessary to solidify your understanding
  • Do any of the exercises that are relevant to helping you understand the material

Topics Covered

  • Test Display Functions
  • Test Display Video

Introduction

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

Test Display Functions

Functions are ... Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

def function_name(arg_1, arg_2):
    pass

Write the functions like this

In [5]:
def my_function(arg_1):
    print("arg_1 is: {}".format(arg_1))

Then call them like this

In [6]:
my_function("test")
arg_1 is: test

Test Display Matplotlib

Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

In [7]:
import numpy as np

import matplotlib
import matplotlib.pyplot as plt

import matplotlib.image as mpimg
In [8]:
x = np.linspace(0, 5, 100)
len(x)
Out[8]:
100
In [9]:
# Linear Function (f(x) = y = x)
x1 = x
y1 = x1
In [10]:
# Quadratic Function (f(x) = y = x^2)
x2 = x
y2 = x**2
In [11]:
# Cubic Function (f(x) = y = x^3)
x3 = x
y3 = x**3

Then plot each of the functions

In [12]:
# A figure with one axes and three functions (MATLAB-style)
plt.plot(x1, y1, label='linear')
plt.plot(x2, y2, label='quadratic')
plt.plot(x3, y3, label='cubic')

plt.xlabel('x values')
plt.ylabel('y values')

plt.title("Three Function Plot")

plt.legend()

print('Current Axes: {}'.format(plt.gca()))
print('Current Figure: {}'.format(plt.gcf()))
Current Axes: AxesSubplot(0.125,0.125;0.775x0.755)
Current Figure: Figure(432x288)
In [11]:
img_fox = mpimg.imread('img/fox.png')
print('Image Shape: {}'.format(img_fox.shape))
plt.imshow(img_fox)
Image Shape: (681, 1024, 3)
Out[11]:
<matplotlib.image.AxesImage at 0x11f0e55d0>

Test Display YTVideo

In [13]:
from IPython.display import YouTubeVideo
In [14]:
# Video: Vectors, what even are they?
# https://www.youtube.com/watch?v=fNk_zzaMoSs&list=PLZHQObOWTQDPD3MizzM2xVFitgF8hE_ab&index=2&t=0s
YouTubeVideo("fNk_zzaMoSs", width=600, height=350, start=0)
Out[14]: