# Bounds Error

**URL:** <https://discourse.julialang.org/t/bounds-error/19060>\
**Category:** General Usage\
**Created:** [December 28, 2018, 3:11pm UTC](https://discourse.julialang.org/t/bounds-error/19060 "2018-12-28T15:11:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![yasirhassan](https://avatars.discourse-cdn.com/v4/letter/y/2bfe46/32.png) [@yasirhassan](https://discourse.julialang.org/u/yasirhassan)\
**Post date:** [December 28, 2018, 3:11pm UTC](https://discourse.julialang.org/t/bounds-error/19060/1 "2018-12-28T15:11:12Z")

</div>

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]

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [December 28, 2018, 3:11pm UTC](https://discourse.julialang.org/t/bounds-error/19060/2 "2018-12-28T15:11:43Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [December 28, 2018, 3:12pm UTC](https://discourse.julialang.org/t/bounds-error/19060/3 "2018-12-28T15:12:24Z")

</div>

f should return a vector to use it with quiver.

---

<div class="post-metadata">

**Author:** ![yasirhassan](https://avatars.discourse-cdn.com/v4/letter/y/2bfe46/32.png) [@yasirhassan](https://discourse.julialang.org/u/yasirhassan)\
**Post date:** [December 28, 2018, 4:25pm UTC](https://discourse.julialang.org/t/bounds-error/19060/4 "2018-12-28T16:25:48Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![yha](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yha/32/3502_2.png) [@yha](https://discourse.julialang.org/u/yha)\
**Post date:** [December 28, 2018, 4:41pm UTC](https://discourse.julialang.org/t/bounds-error/19060/5 "2018-12-28T16:41:22Z")

</div>

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

```julia
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`.
