Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eliocamp/ggperiodic
Easy plotting of periodic data with ggplot2
https://github.com/eliocamp/ggperiodic
ggplot2 r r-package rstats
Last synced: 28 days ago
JSON representation
Easy plotting of periodic data with ggplot2
- Host: GitHub
- URL: https://github.com/eliocamp/ggperiodic
- Owner: eliocamp
- Created: 2018-08-23T03:12:08.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-10-30T18:16:04.000Z (about 1 year ago)
- Last Synced: 2024-09-30T04:05:06.200Z (about 1 month ago)
- Topics: ggplot2, r, r-package, rstats
- Language: R
- Homepage:
- Size: 4.65 MB
- Stars: 21
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
README
---
output: github_document
---```{r setup, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "70%",
cache = FALSE
)
```
# ggperiodic[![Travis build status](https://travis-ci.org/eliocamp/ggperiodic.svg?branch=master)](https://travis-ci.org/eliocamp/ggperiodic)
[![Coverage status](https://codecov.io/gh/eliocamp/ggperiodic/branch/master/graph/badge.svg)](https://codecov.io/github/eliocamp/ggperiodic?branch=master)
[![CRAN_Status_Badge](http://www.r-pkg.org/badges/version/ggperiodic)](https://cran.r-project.org/package=ggperiodic)ggperiodic is an attempt to solve the issue of plotting periodic data in ggplot2. It automatically augments your data to wrap it around to any arbitrary domain.
## Installation
You can install the latest version from CRAN with
``` r
install.packages("ggperiodic")
```Or you can install the development version from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
devtools::install_github("eliocamp/ggperiodic")
```## Example
Let's create some artificial data with periodic domain
```{r}
x <- seq(0, 360 - 10, by = 10)*pi/180
y <- seq(-90, 90, by = 10)*pi/180Z <- expand.grid(x = x, y = y)
Z$z <- with(Z, 1.2*sin(x)*0.4*sin(y*2) -
0.5*cos(2*x)*0.5*sin(3*y) +
0.2*sin(4*x)*0.45*cos(2*x))Z$x <- Z$x*180/pi
Z$y <- Z$y*180/pi
```If you try to plot it, you'll notice problems at the limits
```{r}
library(ggplot2)
ggplot(Z, aes(x, y, z = z, color = ..level..)) +
geom_contour() +
coord_polar()
```With ggperiodic you can define the periodic dimensions and ggplot2 does the rest.
```{r}
library(ggperiodic)
Z <- periodic(Z, x = c(0, 360))ggplot(Z, aes(x, y, color = ..level..)) +
geom_contour(aes(z = z)) +
coord_polar()
```