# arrows

``````arrows(points, directions; kwargs...)
arrows(x, y, u, v)
arrows(x::AbstractVector, y::AbstractVector, u::AbstractMatrix, v::AbstractMatrix)
arrows(x, y, z, u, v, w)``````

Plots arrows at the specified points with the specified components. `u` and `v` are interpreted as vector components (`u` being the x and `v` being the y), and the vectors are plotted with the tails at `x`, `y`.

If `x, y, u, v` are `<: AbstractVector`, then each 'row' is plotted as a single vector.

If `u, v` are `<: AbstractMatrix`, then `x` and `y` are interpreted as specifications for a grid, and `u, v` are plotted as arrows along the grid.

`arrows` can also work in three dimensions.

## Attributes

Available attributes and their defaults for `Arrows` are:

``````  align           :origin
arrowcolor      MakieCore.Automatic()
arrowsize       MakieCore.Automatic()
arrowtail       MakieCore.Automatic()
color           :black
colormap        :viridis
depth_shift     0.0f0
diffuse         0.4
inspectable     true
lengthscale     1.0f0
linecolor       MakieCore.Automatic()
linestyle       "nothing"
linewidth       MakieCore.Automatic()
markerspace     :pixel
normalize       false
overdraw        false
quality         32
shininess       32.0f0
space           :data
specular        0.2
ssao            false
transparency    false
visible         true``````

### Attributes

• `arrowhead = automatic`: Defines the marker (2D) or mesh (3D) that is used as the arrow head. The default for is `'▲'` in 2D and a cone mesh in 3D. For the latter the mesh should start at `Point3f(0)` and point in positive z-direction.

• `arrowtail = automatic`: Defines the mesh used to draw the arrow tail in 3D. It should start at `Point3f(0)` and extend in negative z-direction. The default is a cylinder. This has no effect on the 2D plot.

• `quality = 32`: Defines the number of angle subdivisions used when generating the arrow head and tail meshes. Consider lowering this if you have performance issues. Only applies to 3D plots.

• `linecolor = :black`: Sets the color used for the arrow tail which is represented by a line in 2D.

• `arrowcolor = linecolor`: Sets the color of the arrow head.

• `arrowsize = automatic`: Scales the size of the arrow head. This defaults to `0.3` in the 2D case and `Vec3f(0.2, 0.2, 0.3)` in the 3D case. For the latter the first two components scale the radius (in x/y direction) and the last scales the length of the cone. If the arrowsize is set to 1, the cone will have a diameter and length of 1.

• `linewidth = automatic`: Scales the width/diameter of the arrow tail. Defaults to `1` for 2D and `0.05` for the 3D case.

• `lengthscale = 1f0`: Scales the length of the arrow tail.

• `linestyle = nothing`: Sets the linestyle used in 2D. Does not apply to 3D plots.

• `normalize = false`: By default the lengths of the directions given to `arrows` are used to scale the length of the arrow tails. If this attribute is set to true the directions are normalized, skipping this scaling.

• `align = :origin`: Sets how arrows are positioned. By default arrows start at the given positions and extend along the given directions. If this attribute is set to `:head`, `:lineend`, `:tailend`, `:headstart` or `:center` the given positions will be between the head and tail of each arrow instead.

### Examples

``````using CairoMakie

f = Figure(resolution = (800, 800))
Axis(f[1, 1], backgroundcolor = "black")

xs = LinRange(0, 2pi, 20)
ys = LinRange(0, 3pi, 20)
us = [sin(x) * cos(y) for x in xs, y in ys]
vs = [-cos(x) * sin(y) for x in xs, y in ys]
strength = vec(sqrt.(us .^ 2 .+ vs .^ 2))

arrows!(xs, ys, us, vs, arrowsize = 10, lengthscale = 0.3,
arrowcolor = strength, linecolor = strength)

f`````` ``````using GLMakie

ps = [Point3f(x, y, z) for x in -5:2:5 for y in -5:2:5 for z in -5:2:5]
ns = map(p -> 0.1 * Vec3f(p, p, p), ps)
arrows(
ps, ns, fxaa=true, # turn on anti-aliasing
linecolor = :gray, arrowcolor = :black,
linewidth = 0.1, arrowsize = Vec3f(0.3, 0.3, 0.4),
align = :center, axis=(type=Axis3,)
)`````` ``````using GLMakie

using LinearAlgebra

ps = [Point3f(x, y, z) for x in -5:2:5 for y in -5:2:5 for z in -5:2:5]
ns = map(p -> 0.1 * Vec3f(p, p, p), ps)
lengths = norm.(ns)
arrows(
ps, ns, fxaa=true, # turn on anti-aliasing
color=lengths,
linewidth = 0.1, arrowsize = Vec3f(0.3, 0.3, 0.4),
align = :center, axis=(type=Axis3,)
)``````
{"ft_lang_label":"__label__en","ft_lang_prob":0.70416784,"math_prob":0.9755475,"size":4177,"snap":"2023-14-2023-23","text_gpt3_token_len":1332,"char_repetition_ratio":0.121016055,"word_repetition_ratio":0.12209302,"special_character_ratio":0.2939909,"punctuation_ratio":0.21976866,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97797877,"pos_list":[0,1,2,3,4,5,6],"im_url_duplicate_count":[null,1,null,1,null,1,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-03-30T21:41:48Z\",\"WARC-Record-ID\":\"<urn:uuid:73cfff55-f0d7-4952-b18d-34056dcfaca1>\",\"Content-Length\":\"22189\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:bda63648-b7b5-444e-9613-8745265b5707>\",\"WARC-Concurrent-To\":\"<urn:uuid:752153ad-5268-494e-8fba-6bed7a2e0d55>\",\"WARC-IP-Address\":\"185.199.108.153\",\"WARC-Target-URI\":\"https://docs.makie.org/stable/examples/plotting_functions/arrows/\",\"WARC-Payload-Digest\":\"sha1:N7FTMI2KB5YJDCJAXPS745OQWULZWDCX\",\"WARC-Block-Digest\":\"sha1:CZ2AM4TBDKM3KZ2AIE7XPQK63V3EPTJN\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-14/CC-MAIN-2023-14_segments_1679296949387.98_warc_CC-MAIN-20230330194843-20230330224843-00796.warc.gz\"}"}