https://github.com/Hy4m/ggvwline
https://github.com/Hy4m/ggvwline
Last synced: 6 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/Hy4m/ggvwline
- Owner: Hy4m
- Created: 2021-08-14T08:41:37.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-06-15T13:56:37.000Z (over 3 years ago)
- Last Synced: 2024-11-13T22:35:32.524Z (about 1 year ago)
- Language: R
- Size: 264 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
Awesome Lists containing this project
- awesome-ggplot2 - ggvwline - width curves (Plot layers)
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)
```