Example usage of functions in plot_helpers


In [15]:
%matplotlib notebook
import matplotlib.pyplot as plt
from plot_helpers import plot_vec, plot_vecs, plot_line, plot_plane, autoscale_arrows
import numpy as np
from sympy import *

Plots in the plane


In [16]:
fig = plt.figure()

# plot vectors:
u = Matrix([1,1])
v = Matrix([1,-2])
plot_vecs(u,v)
# same as:
# plot_vec(u)
# plot_vec(v)

# line plot as point + direction form:
plot_line(u,[0,1])

# line plot using normal + constant:  
nvec = Matrix([1,1])
d = 1
plot_plane(nvec,d)    # n_x*x + n_y*y = d


# manual set of plot limits
ax = plt.gca()
ax.set_xlim([-10,10])
ax.set_ylim([-10,10])

# automatic scale (ensure all vectors fit in plot)
# autoscale_arrows()


Out[16]:
(-10, 10)

Three-dimensional plots


In [17]:
fig = plt.figure()


# plot vectors:
u = Matrix([1,1,1])
v = Matrix([1,-2,0])

plot_vecs(u,v)
# same as:
# plot_vec(u)
# plot_vec(v)


# line plot as point + direction form:
plot_line(u,[0,0,1])
plot_line(v,[0,0,1],color='r')

# plane plot using normal + constant:  
plot_plane(u,2)
plot_plane(u,4)
plot_plane(u,8,xrange=[-2,2],yrange=[-2,2])


ax = plt.gca()
ax.set_xlim([-10,10])
ax.set_ylim([-10,10])
ax.set_zlim([-10,10])

# autoscale_arrows()


Out[17]:
(-10, 10)

In [ ]: