-
Notifications
You must be signed in to change notification settings - Fork 5
/
README.Rmd
116 lines (91 loc) · 2.65 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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
---
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%"
)
```
# ggshadow
<!-- badges: start -->
[![CRAN status](https://www.r-pkg.org/badges/version/ggshadow)](https://CRAN.R-project.org/package=ggshadow)
[![License: GPL v2](https://img.shields.io/badge/License-GPL_v2-blue.svg)](https://www.gnu.org/licenses/old-licenses/gpl-2.0.en.html)
[![Lifecycle: stable](https://img.shields.io/badge/lifecycle-stable-brightgreen.svg)](https://lifecycle.r-lib.org/articles/stages.html#stable)
<!-- badges: end -->
The goal of ggshadow is to provide shadow and glow geoms for points and lines plots created with 'ggplot2'.
## :arrow_double_down: Installation
You can install the development version of ggshadow from [GitHub](https://github.com/) with:
``` r
# install.packages("devtools")
pak::pkg_install("marcmenem/ggshadow")
```
## :book: Vignette
```{r vignette}
## after installing the package
# vignette("ggshadow", package = "ggshadow")
```
## :chart: Example
### With ggshadow
```{r example}
library(ggplot2)
library(ggshadow)
ggplot(economics_long, aes(date, value01, colour = variable)) +
geom_shadowline()
```
### Without ggshadow
```{r lineex}
ggplot(economics_long, aes(date, value01, colour = variable)) +
geom_line()
```
### `ggshadow` supports varying the line color
```{r colorvarex}
ggplot(
economics_long,
aes(date, value01,
group = variable,
colour = value01,
shadowlinewidth = 5 * (1 - value01)
)
) +
geom_shadowline(
shadowcolour = "grey",
shadowalpha = 0.5
)
```
### `ggshadow` also provides a Neon glow style
```{r example-glow}
ggplot(economics_long, aes(date, value01, color = variable)) +
geom_glowline() +
guides(color = "none") +
theme(
plot.background = element_rect(fill = "#190132"),
panel.background = element_rect(fill = "#190132")
)
```
### Neon glow points
```{r example-glowpoint}
ggplot(mtcars, aes(wt, mpg)) +
geom_glowpoint(color = "yellow") +
guides(color = "none") +
theme(
plot.background = element_rect(fill = "#190132"),
panel.background = element_rect(fill = "#190132")
)
```
### Adding a fill below the neon glow line
```{r example-glowlinefill}
ggplot(
economics_long[economics_long$variable %in% c("pop", "unemploy"), ],
aes(date, value01 - 0.5, color = variable, fill = variable)
) +
geom_glowline() +
guides(color = "none", shadowcolour = "none", fill = "none") +
theme(
plot.background = element_rect(fill = "#190132"),
panel.background = element_rect(fill = "#190132")
)
```