Quiver plots for ggplot2. An extension of ‘ggplot2’ to provide quiverplots to visualise vector fields. This functionality is implementedusing a geom to produce a new graphical layer, which allows aestheticoptions. This layer can be overlaid on a map to improve visualisation ofmapped data.
Thestable version can be installed from CRAN:
install.packages("ggquiver")Thedevelopment version can be installed from GitHubusing:
# install.packages("remotes")remotes::install_github("mitchelloharawild/ggquiver")ggquiver introduces a new geomgeom_quiver(),which produces a quiver plot inggplot2.
Quiver plots for functions can easily be produced using ggplotaeshetics. When a grid is detected, the size of the vectors areautomatically adjusted to fit within the grid.
library(ggplot2)library(ggquiver)expand.grid(x=seq(0,pi,pi/12),y=seq(0,pi,pi/12))%>%ggplot(aes(x=x,y=y,u=cos(x),v=sin(y)))+geom_quiver()
Theggplot2 example for seal movements is easily reproduced,with appropriately scaled arrowhead sizes. Here, the vecsize is set tozero to not resize the vectors.
ggplot(seals,aes(x=long,y=lat,u=delta_long,v=delta_lat))+geom_quiver(vecsize=0)+borders("state")
Quiver plot arrows can be centered about x and y coordinates, whichis useful when working with maps and scaled vectors.
ggplot(seals,aes(x=long,y=lat,u=delta_long,v=delta_lat))+geom_quiver(vecsize=0,center =TRUE)+borders("state")