-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
75 lines (57 loc) · 1.89 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
---
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%"
)
```
# piechart
<!-- badges: start -->
<!-- badges: end -->
The goal of piechart is to draw a piechart simply and directly based on 'ggplot2'.
## Installation
You can install piechart from [Github](https://github.com) with:
``` r
## install.packages("devtools")
devtools::install_github("Hy4m/piechart")
```
## Example
This is a basic example which shows you how to solve a common problem:
```{r example}
library(piechart)
## random dataset
set.seed(20210515)
dd <- tibble::tibble(value = rpois(20, 5),
label = LETTERS[1:20])
## Ring
piechart(dd, aes(value = value, label = label)) +
geom_pie(aes(fill = label), show.legend = FALSE) +
geom_pie_text()
## Pie
piechart(dd, aes(value = value, label = label), r0 = 0) +
geom_pie(aes(fill = label), show.legend = FALSE) +
geom_pie_text(facing = "clockwise", position = "top-inside")
## sunburst
piechart(dd, aes(r1 = value, label = label), value = 1, r0 = 0.5) +
geom_pie(aes(fill = label), show.legend = FALSE) +
geom_pie_text(facing = "clockwise", position = "top-inside")
piechart(dd, aes(r1 = value, label = label), value = 1, r0 = 0.5,
sort_by = "value") +
geom_pie(aes(fill = value), show.legend = FALSE) +
geom_pie_text(facing = "clockwise", position = "top-inside") +
ggplot2::scale_fill_viridis_c()
## arc heatmap
library(magrittr)
as.matrix(iris[-5]) %>%
as_piechart_data(start = 80, end = 100, r0 = 0.8) %>%
piechart(xlim = c(-1.2, 1.2), ylim = c(-1.2, 1.2)) +
geom_pie(aes(fill = value), colour = "white", size = 0.3) +
geom_rtext(position = "top-outside", size = 2.5) +
geom_ctext(hjust = "middle", size = 2.5) +
ggplot2::scale_fill_viridis_c()
```