Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

R package for quiver plots in 'ggplot2'

NotificationsYou must be signed in to change notification settings

mitchelloharawild/ggquiver

Repository files navigation

R-CMD-checkCRAN_Status_BadgeDownloads

ggquiverggquiver website

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.

Installation

Thestable version can be installed from CRAN:

install.packages("ggquiver")

Thedevelopment version can be installed from GitHub using:

# install.packages("remotes")remotes::install_github("mitchelloharawild/ggquiver")

Usage

ggquiver introduces a new geomgeom_quiver(), which produces aquiver 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, withappropriately scaled arrowhead sizes. Here, the vecsize is set to zeroto not resize the vectors.

library(maps)world<-sf::st_as_sf(map('world',plot=FALSE,fill=TRUE))ggplot(seals)+   geom_quiver(    aes(x=long,y=lat,u=delta_long,v=delta_lat),vecsize=0  )+   geom_sf(data=world)+  coord_sf(xlim= c(-173.8,-117.8),ylim= c(28.7,50.7),expand=FALSE)+   labs(title="Seal movements",x=NULL,y=NULL)

Quiver plot arrows can be centered about x and y coordinates, which isuseful when working with maps and scaled vectors.

ggplot(seals)+   geom_quiver(    aes(x=long,y=lat,u=delta_long,v=delta_lat),vecsize=0,center=TRUE  )+   geom_sf(data=world)+  coord_sf(xlim= c(-173.8,-117.8),ylim= c(28.7,50.7),expand=FALSE)+   labs(title="Seal movements (centered arrows)",x=NULL,y=NULL)

About

R package for quiver plots in 'ggplot2'

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages


[8]ページ先頭

©2009-2025 Movatter.jp