예제 #1
0
파일: surf.py 프로젝트: johnyf/pyvectorized
"""
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)
예제 #2
0
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()
quiver(x, v, ax)

streamplot(x, v, res, ax,
           density=1, color='red')

"""
quiver 3d
"""
dom = [-1, 1, -1, 1, -1, 1]
res = [5, 5, 5]