-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
executable file
·111 lines (80 loc) · 2.7 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
---
# to markdown
output: md_document
---
`ohmyggplot`
==============================================================================
```{r setup, include=FALSE}
suppressPackageStartupMessages({
library(dplyr)
library(ggplot2)
library(ohmyggplot)
})
knitr::opts_chunk$set(echo = TRUE)
```
Your ggplot2 with better defaults.
Without `ohmyggplot`
------------------------------------------------------------------------------
```{r}
library(ggplot2)
library(patchwork)
p1 = ggplot(iris) +
geom_point(aes(Sepal.Length, Sepal.Width, color = Petal.Length), alpha = 0.8) +
theme(legend.position = "top") +
labs(title = "A dull plot, isn't it?")
p2 = ggplot(iris) +
geom_point(aes(Sepal.Length, Sepal.Width, color = Species), alpha = 0.8)
p1 + p2
```
With `ohmyggplot`
------------------------------------------------------------------------------
```{r}
library(ohmyggplot)
#initiate ohmyggplot
oh_my_ggplot()
p = ggplot(iris) +
geom_point(aes(Sepal.Length, Sepal.Width, fill = Petal.Length), alpha = 0.8) +
theme(legend.position = "top") +
labs(title = "A better plot, without extra code!") +
better_fill_legend
p
```
New geoms: `geom_caviar`
------------------------------------------------------------------------------
```{r}
p = ggplot(iris, aes(Sepal.Length, Sepal.Width)) +
geom_caviar(aes(color = Petal.Length)) +
theme(legend.position = "top") +
labs(subtitle = "Bordered scatter plot with geom_caviar") +
better_fill_legend
p
```
Even better with `ggRetro`
------------------------------------------------------------------------------
```{r}
library(ggRetro)
ggRetro::base_mode(p) +
theme(legend.position = "top") +
labs(title = "Now with floating axes!")
```
The default descret color is also changed to Nature Publication Group style, from `ggsci::npg`
------------------------------------------------------------------------------
```{r}
ggRetro::base_mode({
ggplot(iris) +
geom_point(aes(Sepal.Length, Sepal.Width, fill = Species), alpha = 0.8)
}) +
theme(legend.position = "top")
```
Installation
------------------------------------------------------------------------------
```{}
remotes::install_github("albert-ying/ohmyggplot")
# Or
devtools::install_github("albert-ying/ohmyggplot")
```
Acknowledgements
------------------------------------------------------------------------------
This package is inspired by Dr. Cédric Scherer's talk [{ggplot2} Wizardry](https://www.youtube.com/watch?v=5KHvEXYtnOo&ab_channel=UseROslo)
The default theme is build on [`hrbrthemes`](https://github.com/hrbrmstr/hrbrthemes).
The default color is from [`ggsci`](https://nanx.me/ggsci/)