In [15]:
using Plots
pyplot(leg=false, size=(500,300))

n = 10
y = rand(n)
vx, vy = randn(n), randn(n)

quiver(y, quiver=(vx,vy))


Out[15]:

In [21]:
e(x,y) = exp(-x^2-y^2)
f(x,y) = x * e(x,y)
x = -2:0.2:2
contour(x,x,f, xlim=(-2,2), ylim=(-2,2), fill=true)


Out[21]:

In [22]:
# take the derivative, then scale down
df(x,y) = P2(e(x,y) + x * e(x,y) * (-2x), x * e(x,y) * (-2y)) / 4

# get a grid of points as a vector
pts = vec(P2[(x[i],x[j]) for i=1:length(x), j=1:length(x)])

# add the quiver plot
quiver!(pts, quiver=df, marker=(:none,stroke(2,0.3)))


Out[22]:

In [ ]: