View source: R/annotation_fields.r
annotation_fields | R Documentation |
Functions exactly the same as geom_fields()
, with that difference
that this function does not train the x
and y
scales. This
makes the data central, and uses this layer to support it. Consequently,
annotation_fields()
does not accept a stat
argument.
annotation_fields(
mapping = NULL,
data = NULL,
position = "identity",
na.rm = FALSE,
show.legend = NA,
max_radius = ggplot2::unit(0.5, "cm"),
.angle_correction = angle_correction,
arrow = grid::arrow(length = ggplot2::unit(0.2, "cm")),
inherit.aes = TRUE,
...
)
mapping |
Set of aesthetic mappings created by |
data |
Can be one of four things:
|
position |
A position adjustment to use on the data for this layer. This
can be used in various ways, including to prevent overplotting and
improving the display. The
|
na.rm |
If |
show.legend |
logical. Should this layer be included in the legends?
|
max_radius |
Maximum radius to which the |
.angle_correction |
Function to correct the angle in the aesthetics for the projection and/or
aspect ratio used in the plot. When set to |
arrow |
specification for arrow heads, as created by |
inherit.aes |
If |
... |
Other arguments passed on to
|
A ggplot2::layer_sf()
.
Pepijn de Vries
if (requireNamespace("stars") && requireNamespace("ggplot2")) {
library(stars)
library(ggplot2)
data("seawatervelocity")
sw_sub <- seawatervelocity[,8:13,1:5]
## Note that the `seawatervelocity` spans a much larger area,
## but the plot only focuses on `sw_sub`
ggplot() +
geom_stars(data = sw_sub) +
annotation_fields(data = seawatervelocity,
aes(angle = as.numeric(atan2(vo, uo)),
radius = as.numeric(pythagoras(uo, vo)))) +
labs(radius = "v [m/s]")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.