Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/Hy4m/ggvwline


https://github.com/Hy4m/ggvwline

Last synced: about 2 months ago
JSON representation

Awesome Lists containing this project

README

        

---
output: github_document
---

```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```

# ggvwline

The purpose of `ggvwline` is to provide a set of layer functions for drawing variable-width curves.

## Installation

You can install the development version of ggvwline from [GitHub](https://github.com/) with:

``` r
# install.packages("devtools")
devtools::install_github("Hy4m/ggvwline")
```

## Example

This is a basic example which shows you how to draw variable-width curves:

```{r example}
library(ggvwline)
library(ggplot2)
tt <- seq(0, 2 * pi, length.out = 102)[-c(1, 102)]
dd <- data.frame(x = cos(tt),
y = sin(tt),
w = runif(100, 10, 30),
g = rep(LETTERS[1:4], each = 25))

ggplot(dd, aes(x, y, fill = g)) +
geom_vwline() +
coord_fixed()

ggplot(dd, aes(x, y, fill = g)) +
geom_offset_xspline(aes(width = w)) +
coord_fixed()

dd2 <- data.frame(x = 1,
y = 1:10,
xend = 2:11,
yend = 3:12,
width = runif(10, 3, 20),
group = LETTERS[1:10])

ggplot(dd2, aes(x, y, xend = xend, yend = yend)) +
geom_vwdiagonal(aes(width = stat(index), fill = group),
width_units = "cm",
lineend = "round",
alpha = 0.5)
```