-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathreadme.Rmd
213 lines (143 loc) · 5.5 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
---
title: "ggCyberPunk"
author: "Joshua de la Bruere"
date: "4/2/2020"
output: github_document
---
<!-- badges: start -->
[![R-CMD-check](https://github.com/delabj/ggCyberPunk/workflows/R-CMD-check/badge.svg)](https://github.com/delabj/ggCyberPunk/actions)
<!-- badges: end -->
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
knitr::opts_chunk$set(dev.args = list(png = list(type = "cairo")))
```
```{r echo = F, message=F, warning=F}
library(tidyverse)
library(ggCyberPunk)
df = data.frame(A=c(1,4,4,6,7,5,1),
B=c(4,3,5,7,5,6,7),
Time=c(1,2,3,4,5,6,7)) %>%
pivot_longer(cols = c(A,B),names_to = "group", values_to = "count")
df %>%
ggplot(aes(x=Time, y = count, color = group, fill= group))+
geom_glowing_area()+
theme_cyberpunk()+
scale_fill_cyberpunk("cotton candy")+
scale_color_cyberpunk("cotton candy")+
ggtitle("Introducing Cyberpunk plots", subtitle = "Using ggCyberPunk")
```
## Installation
This isn't on CRAN, so you'll have to use devtools.
``devtools::install_github("delabj/ggCyberPunk")``
## Dependancies
This package uses extrafont to install the cyberpunk font. If you don't want to use this, you can always specify a font that your system has installed and the R recongnizes.
This package also uses ggplot2, this is required for the plot to actually function.
Additionally, dplyr is used to make some of the internal code a bit more readable.
## Why?
The other day, I saw a post on [reddit](https://www.reddit.com/r/rstats/comments/fsncqz/cyberpunk_plots_in_r/) asking if there was a way to create a "CyberPunk plot" in R. This was based on plots produced in python using matplotlib as shown on [this repo](https://github.com/dhaitz/mplcyberpunk). Since it's the end times, and I have nothing better to do at home than poke around with a theme, this seemed like a perfect fit.
If you want more cyberpunk themed plot options, palettes, and themes, check out [vapoRwave](https://github.com/moldach/vapoRwave), from which I totally stole the base theme for this package. A few modifications, but it's very much the new_retro theme.
## What's in the box?
### geom_glowing_area()
A glowing area plot for a cyberpunk/disco/neon vibe.
#### Useage
geom_glowing_area(alpha = 1, size = 1, glow_alpha = 0.03)
#### Arguments
`alpha`: the alpha level of the base line
`size`: size of the base line
`glow_alpha`: set the alpha level of the glow layers
#### Example
```{r, message=F, warning=F}
library(tidyverse)
library(ggCyberPunk)
df = data.frame(A=c(1,4,4,6,7,5,1),
B=c(4,3,5,7,5,6,7),
Time=c(1,2,3,4,5,6,7)) %>%
pivot_longer(cols = c(A,B),names_to = "group", values_to = "count")
df %>%
ggplot(aes(x=Time, y = count, color = group, fill= group))+
geom_glowing_area()+
theme_cyberpunk()+
scale_fill_cyberpunk("zune")+
scale_color_cyberpunk("zune")+
ggtitle("geom_glowing_area()", subtitle = "From ggCyberPunk")
```
### geom_glowing_line()
A glowing line plot for a cyberpunk/disco/neon vibe.
#### Useage
geom_glowing_line(alpha = 1, size = 1, glow_alpha = 0.03)
#### Arguments
`alpha`: the alpha level of the base line
`size`: size of the base line
`glow_alpha`: set the alpha level of the glow layers
#### Example
```{r, message=F, warning=F}
library(tidyverse)
library(ggCyberPunk)
df = data.frame(A=c(1,4,4,6,7,5,1),
B=c(4,3,5,7,5,6,7),
Time=c(1,2,3,4,5,6,7)) %>%
pivot_longer(cols = c(A,B),names_to = "group", values_to = "count")
df %>%
ggplot(aes(x=Time, y = count, color = group, fill= group))+
geom_glowing_line()+
theme_cyberpunk()+
scale_color_cyberpunk()+
ggtitle("geom_glowing_line()", subtitle = "From ggCyberPunk")
```
### geom_linesaber()
A glowing line plot for a laser sword look.
#### Useage
geom_linesaber(alpha = 1, size = 1, glow_alpha = 0.03)
#### Arguments
`alpha`: the alpha level of the base line
`size`: size of the base line
`glow_alpha`: set the alpha level of the glow layers
#### Example
```{r, message=F, warning=F}
library(tidyverse)
library(ggCyberPunk)
df = data.frame(A=c(1,4,4,6,7,5,1),
B=c(4,3,5,7,5,6,7),
Time=c(1,2,3,4,5,6,7)) %>%
pivot_longer(cols = c(A,B),names_to = "group", values_to = "count")
df %>%
ggplot(aes(x=Time, y = count, color = group, fill= group))+
geom_linesaber()+
theme_cyberpunk()+
scale_color_linesaber(reverse = T)+
ggtitle("geom_linesaber()", subtitle = "From ggCyberPunk")
```
## Also included are palettes
### main
```{r,echo=F, warning=F, message=F}
scales::show_col(c('cyber1 blue' = "#08F7FE",
'cyber2 pink' = "#E64E8D",
'cyber3 yellow' = "#ECCE8E",
'cyber4 orange' = "#EE9537"))
```
### Cotton Candy
```{r,echo=F, warning=F, message=F}
scales::show_col(c('cyber1 blue' = "#08F7FE",
'cyber2 pink' = "#E64E8D"))
```
### zune
```{r,echo=F, warning=F, message=F}
scales::show_col(c(
'cyber2 pink' = "#E64E8D",
'cyber4 orange' = "#EE9537"))
```
### laser sword
```{r,echo=F, warning=F, message=F}
scales::show_col(c( 'saber2 green' = "#32CD32",
'saber3 red' = "#B22222",
'saber4 purple' = "#8510d8",
'saber1 blue' = "#49f9fe"))
```
## scale_fill_cyberpunk/scale_color_cyberpunk
### usage
`scale_fill_cyber_punk(palette = "main", discrete = T, reverse = F )`
`scale_color_cyber_punk(palette = "main", discrete = T, reverse = F )`
## scale_fill_linesaber/scale_color_linesaber
### usage
`scale_fill_linesaber(palette = "main", discrete = T, reverse = F )`
`scale_color_linesaber(palette = "main", discrete = T, reverse = F )`