# How to scale vector filed plots by the norm?

**URL:** <https://discourse.julialang.org/t/how-to-scale-vector-filed-plots-by-the-norm/62186>\
**Category:** Visualization\
**Tags:** question, makie\
**Created:** [June 1, 2021, 1:04pm UTC](https://discourse.julialang.org/t/how-to-scale-vector-filed-plots-by-the-norm/62186 "2021-06-01T13:04:21Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SebastianM-C](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sebastianm-c/32/2480_2.png) [@SebastianM-C](https://discourse.julialang.org/u/SebastianM-C)\
**Post date:** [June 1, 2021, 1:04pm UTC](https://discourse.julialang.org/t/how-to-scale-vector-filed-plots-by-the-norm/62186/1 "2021-06-01T13:04:21Z")

</div>

I am writing a plot recipe for [plotting vector fields in a package](https://github.com/SebastianM-C/PICDataStructures.jl/blob/71620b00fb7650cfeada6e1888101ac9855c2d23/src/recipes/abstractplotting.jl#L155-L186). I would like to have an `arrow` plot where the maximum arrow length and arrow size are fixed in Pixel units and all the arrows have their tail length and arrow size proportional to the respective vector norm (this way I also avoid visual clutter from very small vectors).

From [the docs](https://makie.juliaplots.org/stable/plotting_functions/arrows.html) I understand that `lengthscale` and `arrowsize` are in data units. Is there a way to give them in `Pixel` units? Or can I get the scene limits inside the type recipe to compute the required factors?

---

<div class="post-metadata">

**Author:** ![ffreyer](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ffreyer/32/21569_2.png) [@ffreyer](https://discourse.julialang.org/u/ffreyer)\
**Post date:** [June 1, 2021, 2:05pm UTC](https://discourse.julialang.org/t/how-to-scale-vector-filed-plots-by-the-norm/62186/2 "2021-06-01T14:05:17Z")

</div>

`arrowsize` affects just the triangle/cone part and is in pixel space in 2d. `lengthscale` is a multiplier to the directions you pass and affects the length of the line/cylinder part.

With `lengthscale = 1` (default) the length of arrow tails is the norm of the directions. If you want the heads to also scale you could try something like `arrowscale = lift(v -> 10norm(v), dirs)`.
