# Quiver plot arrowhead sizing

**URL:** <https://discourse.julialang.org/t/quiver-plot-arrowhead-sizing/81789>\
**Category:** Visualization\
**Tags:** plotting, plots, makie\
**Created:** [May 27, 2022, 2:35pm UTC](https://discourse.julialang.org/t/quiver-plot-arrowhead-sizing/81789 "2022-05-27T14:35:37Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [May 27, 2022, 9:44pm UTC](https://discourse.julialang.org/t/quiver-plot-arrowhead-sizing/81789/4 "2022-05-27T21:44:18Z")

</div>

You can try the user function `arrow0!()`, broadcasted as in example further below and which depends only on Plots.jl, as an alternative to `quiver!()`.  
(_data example based_ [_on this other post_](https://discourse.julialang.org/t/how-to-plot-quiver-plot-over-heatmap/66000/2))

 ![Plots_gr_arrow0_quiver_with_variable_arrowheads](https://global.discourse-cdn.com/julialang/original/3X/5/2/5250c52af002c5e2e6de0a246e1b246136dc9eb5.png)

> **Plots.jl code**
>
> ```julia
> # 1 - INPUT DATA
> using ForwardDiff
> const ∂ = ForwardDiff.derivative
> 
> f(x, y) = y * exp(-(x^2 + y^2))
> u_(x, y) = -∂(Base.Fix2(f, y), x)
> v_(x, y) = -∂(Base.Fix1(f, x), y)
> 
> lims = (-2.2, 2.2)
> xs = ys = range(lims...; length=200)
> c = 0.3
> x = y = range(-2.0, 2.0; length=15)
> X, Y = reim(complex.(x', y)) # meshgrid
> U, V = c*u_.(x', y), c*v_.(x', y)
> 
> # 2 - PLOT DATA
> using Plots; gr(legend=false, dpi=600)
> 
> # as: arrow head size 0-1 (fraction of arrow length; la: arrow alpha transparency 0-1
> function arrow0!(x, y, u, v; as=0.07, lw=1, lc=:black, la=1)
> nuv = sqrt(u^2 + v^2)
> v1, v2 = [u;v] / nuv, [-v;u] / nuv
> v4 = (3*v1 + v2)/3.1623 # sqrt(10) to get unit vector
> v5 = v4 - 2*(v4'*v2)*v2
> v4, v5 = as*nuv*v4, as*nuv*v5
> plot!([x,x+u], [y,y+v], lw=lw, lc=lc, la=la)
> plot!([x+u,x+u-v5[1]], [y+v,y+v-v5[2]], lw=lw, lc=lc, la=la)
> plot!([x+u,x+u-v4[1]], [y+v,y+v-v4[2]], lw=lw, lc=lc, la=la)
> end
> 
> # Alternative to: quiver!(vec(X-U/2), vec(Y-V/2); quiver=(vec(U), vec(V)), color=:red)
> # Plot points and arrows with 30% head sizes
> heatmap(xs, ys, f, title="arrow0!", lims=lims, ratio=1)
> arrow0!.(X, Y, U, V; as=0.3, lw=0.5,lc=:red, la=1);
> Plots.current()
> 
> ```

---

_[View the full topic](https://discourse.julialang.org/t/quiver-plot-arrowhead-sizing/81789)._
