| geom_azimuth | R Documentation |
geom_azimuth() visualizes axial-directional vector fields using a geom to
produce a new graphical layer, which allows aesthetic options.
This layer can be overlaid on a map to improve visualisation of mapped data.
The geom draws line segments (spokes) centered at (x, y) with a given
orientation (angle in degrees) and length (radius). By default the spoke
is centered using PositionCenterSpoke, so that the given coordinates mark
the middle of the line. The azimuths are given as angles in degrees increasing clockwise from North.
geom_azimuth(
mapping = NULL,
data = NULL,
stat = "azimuth",
center = TRUE,
radius = NULL,
na.rm = FALSE,
show.legend = NA,
inherit.aes = TRUE,
...
)
mapping |
Set of aesthetic mappings created by |
data |
A data frame. If |
stat |
The statistical transformation to use on the data. Defaults to
|
center |
Logical; if |
radius |
Length of spoke |
na.rm |
If |
show.legend |
Logical. Should this layer be included in the legends? |
inherit.aes |
If |
... |
Other arguments passed on to |
A ggplot2 layer that adds axis-like spokes.
geom_azimuth() understands the following aesthetics (required aesthetics in bold):
x
y
angle (in degrees, transformed internally)
radius
colour
alpha
linewidth
linetype
ggplot2::geom_spoke(), geom_azimuthpoint()
set.seed(20250411)
df <- data.frame(
x = runif(5), y = runif(5),
angle_deg = rvm(5, mean = 90, kappa = 10),
radius = runif(5, 0.1, 2)
)
if (require("ggplot2")) {
ggplot(df, aes(x, y)) +
geom_azimuth(aes(angle = angle_deg), radius = .1, linewidth = 1.2, colour = "blue")
if (require("grid")) {
ggplot(df, aes(x, y, radius = radius)) +
geom_azimuth(aes(angle = angle_deg), center = FALSE, colour = "red", arrow = grid::arrow())
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.