Example #1
0
surf example
"""
from pyvectorized import dom2vec, surf, \
    newax, axis, axeq, hold, grid, gridhold

def myfun(x):
    return x[0,:]**2 +x[1,:]**3

domain = [0, 1,0, 2]
resolution = [20, 30]

q = dom2vec(domain, resolution)

f = myfun(q)

ax, fig = newax(1, dim=[3])
surf(q, f, resolution, ax=ax)

axis(ax, domain +[0, 10])
axeq(ax)

"""manage multiple axes"""
ax2, fig = newax(1, dim=[3])
surf(q, -f, resolution, ax=ax2)

axs =[ax, ax2]

hold(axs)
grid(axs)

# shorthand for above
Example #2
0
"""
plot 2d, 3d
"""
from pyvectorized import newax, dom2vec, \
    plot, quiver, text, streamplot, axis
import numpy as np

x = np.arange(10)
y = np.square(x)
q2 = np.vstack([x, y])

t = np.arange(10)
q = np.vstack([t, np.sin(t), np.cos(t) ])

ax, fig = newax(2, dim=[2,3])

plot(q2, ax[0])
plot(q, ax[1])

"""
quiver 2d
"""
dom = [-10, 10, -10, 10]
res = [10, 10]

x = dom2vec(dom, res)
A = np.array([[1, -2],
              [2, 1] ])
v = A.dot(x)

ax, fig = newax()