Bounds Error

i am trying to run following code:
using Plots
gr()
X = Y = collect( range(-10, stop=10, length=100))
f(x, y) = exp.(-x.^2 .- y.^2)
contour(X, Y, f)
quiver!(X, Y’, quiver=f, c=:blue)

bounds error is thrown:
ERROR: LoadError: BoundsError: attempt to access 2.572209372642415e-56
at index [2]

Try removing all the dots from the definition of f. (Untested)

f should return a vector to use it with quiver.

f(x, y) = exp(-x^2-y^2)
quiver!(X, Y, quiver=f, c=:blue)
i tried but didn’t work!

The quiver parameter takes a function mapping two arguments (x,y coordinates) to a 2-vector for the arrow. Your function returns a scalar instead of a vector.
I’m not sure what you’re trying to plot, but you can do, for example

X = Y = range(-10, stop=10, length=10)
quiver(X, Y', quiver=(x,y)->[x,y], c=:blue)

Also, there’s no need to call collect.

2 Likes