-
Notifications
You must be signed in to change notification settings - Fork 1
/
README.Rmd
99 lines (74 loc) · 3.44 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
---
output: github_document
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```
# arcET
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
<!-- badges: end -->
In some cases, the polar-coordinate plot in 'ggplot2' are not flexible enough to meet actual needs. In contrast, the 'circlize' package is flexible enough, but too complex for beginners. This package provides a compromise solution that helps beginners to draw fast and well, and also allows advanced users to use flexibly.
## Installation
You can install the development version of arcET like so:
``` r
## install.packages("devtools")
devtools::install_github("Hy4m/arcET", force = TRUE)
```
## Example
This is a basic example which shows you how to solve a common problem:
```{r example}
library(arcET)
library(ggplot2)
## ggplot2 plot
ggplot(mtcars, aes(wt, mpg)) + geom_point()
## transform
arc_test()
```
```{r example2}
library(arcET)
library(ggplot2)
## ggplot2 plot
p <- ggplot(mtcars, aes(wt, mpg)) + geom_point()
arcplot() |>
init_cell(p, region = CELL(180, 0, 0.5)) |>
within_plot(title = "wt vs mpg",
xlim = c(-1.1, 1.1),
ylim = c(-0.1, 1.1)) |>
decorate_rect(ymin = 1,
ymax = 1.1,
fill = "steelblue",
colour = NA,
CellID = "CellID",
fixed = FALSE) |>
decorate_bannertext(label = "Bannertext annotation has done",
y = 1.05,
colour = "red",
CellID = "CellID",
fixed = FALSE)
```
## `region` parameter
The `region` parameter (created by `CELL()` function) is used to set the region location in polar coordinates, and it mainly has the following four parameters: `start` and `end` are used to set the angle (in degree) position of the start and end of the region; `r0` and `r1` are used to set the radius of the start and end of the region. In addition, the `direct` parameter controls the direction of the region. The default of `direct` parameter is `clockwise`, but you can set to `reverse.clockwise`.
The `show_cell()` function is a quick way to visualize what different parameters do:
```{r cell}
region <- CELL(start = 120, end = 60, r0 = 0.5, r1 = 1)
region ## print
show_cell(region) ## visualize
## reverse.clockwise
region2 <- CELL(start = 120, end = 60, r0 = 0.5, r1 = 1,
direct = "reverse.clockwise")
show_cell(region2)
## combine
show_cell(CELL(start = 120, end = 60, r0 = 0.5, r1 = 1),
CELL(start = 140, end = 40, r0 = 0.5, r1 = 1,
direct = "reverse.clockwise"))
```
## Notes
It is still in the phase of code testing and updating help documentation, so many features and usage you may not be able to find the corresponding documentation. In addition, `arcET` currently does not support the special layer functions provided in other `ggplot2` extensions, and of course I welcome everyone to submit PR to improve the `arcET` package.
Finally, it must be noted that many functions in the `arcET` package refer to or copy the corresponding function code in the `ggplot2` package, and if I did not comment clearly in the source code, please point out or submit an PR to fix it.