Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mitchelloharawild/ggquiver
R package for quiver plots in 'ggplot2'
https://github.com/mitchelloharawild/ggquiver
ggplot2 plot quiver r velocity
Last synced: 7 days ago
JSON representation
R package for quiver plots in 'ggplot2'
- Host: GitHub
- URL: https://github.com/mitchelloharawild/ggquiver
- Owner: mitchelloharawild
- Created: 2017-08-09T10:41:30.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-11-18T08:46:30.000Z (12 months ago)
- Last Synced: 2024-04-26T08:41:29.857Z (7 months ago)
- Topics: ggplot2, plot, quiver, r, velocity
- Language: R
- Homepage: http://pkg.mitchelloharawild.com/ggquiver
- Size: 6.73 MB
- Stars: 50
- Watchers: 6
- Forks: 3
- Open Issues: 2
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
README
---
output: github_document
---```{r, echo = FALSE, message=FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
fig.path = "man/figures/README-",
comment = "#>"
)
library(ggquiver)
library(dplyr)
```[![R-CMD-check](https://github.com/mitchelloharawild/ggquiver/workflows/R-CMD-check/badge.svg)](https://github.com/mitchelloharawild/ggquiver/actions)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/ggquiver)](https://cran.r-project.org/package=ggquiver)
[![Downloads](http://cranlogs.r-pkg.org/badges/ggquiver?color=brightgreen)](https://cran.r-project.org/package=ggquiver)# ggquiver
Quiver plots for ggplot2. An extension of 'ggplot2' to provide quiver plots to
visualise vector fields. This functionality is implemented 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.## Installation
The **stable** version can be installed from CRAN:
```{r, eval = FALSE}
install.packages("ggquiver")
```The **development** version can be installed from GitHub using:
```{r, eval = FALSE}
# install.packages("remotes")
remotes::install_github("mitchelloharawild/ggquiver")
```## Usage
*ggquiver* introduces a new geom `geom_quiver()`, which produces a quiver plot in *ggplot2*.
Quiver plots for functions can easily be produced using ggplot aeshetics. When a grid is detected, the size of the vectors are automatically adjusted to fit within the grid.
```{r quiverplot}
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()
```The *ggplot2* example for seal movements is easily reproduced, with appropriately scaled arrowhead sizes. Here, the vecsize is set to zero to not resize the vectors.
```{r sealplot}
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, which is useful when working with maps and scaled vectors.
```{r sealplot-centered}
ggplot(seals, aes(x=long, y=lat, u=delta_long, v=delta_lat)) +
geom_quiver(vecsize=0, center = TRUE) +
borders("state")
```