The hardware and bandwidth for this mirror is donated by METANET, the Webhosting and Full Service-Cloud Provider.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]metanet.ch.
Add vector field layers to your ggplot2::ggplot()
.
Although it has similarities with ggplot2::geom_spoke()
,
ggfields
offers some distinct features:
radius
aesthetic is mapped to a scale and therefore
can be added to the guides (see
vignette("radius_aes")
).data.frame
s are supported, but also geometric
data (sf::st_sf()
and
stars::st_as_stars()
).vignette("angle_correction")
).Get CRAN version
install.packages("ggfields")
Get development version from r-universe
install.packages("ggfields", repos = c("https://pepijn-devries.r-universe.dev", "https://cloud.r-project.org"))
The example below shows how seawater current data can be added to a map:
library(ggplot2)
library(ggfields)
library(ggspatial) ## For annotating with Open Street Map
data(seawatervelocity)
ggplot() +
::annotation_map_tile(
ggspatialalpha = 0.25,
cachedir = tempdir()) +
geom_fields(
data = seawatervelocity,
aes(radius = as.numeric(v),
angle = as.numeric(angle),
colour = as.numeric(v)),
max_radius = grid::unit(0.7, "cm")) +
labs(colour = "v[m/s]",
radius = "v[m/s]") +
scale_radius_binned() +
scale_colour_viridis_b(guide = guide_bins())
Vector arrows can also be added to simple plots with x
and y
data:
## First generate some arbitrary data to plot:
<- 10
n <- data.frame(x = seq(0, 100, length.out = n), y = rnorm(n),
df ang = seq(0, 2*pi, length.out = n))
$len <- 2 + df$y + rnorm(n)/4
df
ggplot(df, aes(x = x, y = y)) +
geom_line() +
geom_fields(aes(angle = ang, radius = len), .angle_correction = NULL)
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.