-
-
Notifications
You must be signed in to change notification settings - Fork 20
/
README.Rmd
147 lines (109 loc) · 4.78 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
---
output: github_document
always_allow_html: yes
---
<!-- README.md is generated from README.Rmd. Please edit that file -->
```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/"
)
```
# ggeasy <img src='man/figures/logo.gif' align="right" height="138.5" />
<!-- http://www.clker.com/clipart-2-puzzle-pieces-connected.html -->
[![Covrpage Summary](https://img.shields.io/badge/covrpage-Last_Build_2023_03_11-brightgreen.svg)](https://github.com/jonocarroll/ggeasy/blob/master/tests/README.md)
[![AppVeyor build status](https://ci.appveyor.com/api/projects/status/github/jonocarroll/ggeasy?branch=master&svg=true)](https://ci.appveyor.com/project/jonocarroll/ggeasy)
[![R-CMD-check](https://github.com/jonocarroll/ggeasy/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/jonocarroll/ggeasy/actions/workflows/R-CMD-check.yaml)
[![Codecov test coverage](https://codecov.io/gh/jonocarroll/ggeasy/branch/master/graph/badge.svg)](https://app.codecov.io/gh/jonocarroll/ggeasy?branch=master)
[![CRAN status](https://www.r-pkg.org/badges/version/ggeasy)](https://CRAN.R-project.org/package=ggeasy)
You know how to make `ggplot2` graphics, right? No worries. Piece of cake.
Now, can you please rotate the `x` axis labels to vertical?
![](https://raw.githubusercontent.com/jonocarroll/ggeasy/master/inst/media/xkcd.png)
<!-- ![](https://raw.githubusercontent.com/jonocarroll/ggeasy/master/inst/media/winona.gif) -->
<!-- ![](https://raw.githubusercontent.com/jonocarroll/ggeasy/master/inst/media/sherlock.gif) -->
`ggeasy` is here to make that a little easier.
## Installation
You can install the latest released version of `ggeasy` from CRAN with:
```{r cran-installation, eval = FALSE}
install.packages("ggeasy")
```
or the bleeding-edge development version from GitHub with
```{r gh-installation, eval = FALSE}
# install.packages("remotes")
remotes::install_github("jonocarroll/ggeasy")
```
## Reference
See the [`pkgdown` site](https://jonocarroll.github.io/ggeasy/).
[\@amrrs](https://github.com/amrrs) a.k.a. [\@1littlecoder](https://twitter.com/1littlecoder) has produced a video walkthrough using `ggeasy` which covers some of the major features:
[![Watch the video](https://img.youtube.com/vi/iAH1GJoBZmI/maxresdefault.jpg)](https://youtu.be/iAH1GJoBZmI)
[Sharon Machlis](https://www.infoworld.com/profile/sharon-machlis/) has a great [article](https://www.infoworld.com/article/2256726/easier-ggplot-with-the-ggeasy-r-package.html) detailing using the package, as well as a video
[![Watch the video](https://img.youtube.com/vi/-2ZvQQ583pI/maxresdefault.jpg)](https://www.youtube.com/watch?v=-2ZvQQ583pI)
## Examples
```{r example}
library(ggplot2)
library(ggeasy)
# rotate x axis labels
ggplot(mtcars, aes(hp, mpg)) +
geom_point() +
easy_rotate_x_labels()
# rotate y axis labels
ggplot(mtcars, aes(hp, mpg)) +
geom_point() +
easy_rotate_y_labels()
# remove 'size' legend
ggplot(mtcars, aes(wt, mpg, colour = cyl, size = hp)) +
geom_point() +
easy_remove_legend(size)
# make the x axis labels larger
ggplot(mtcars, aes(mpg, hp)) +
geom_point() +
easy_x_axis_labels_size(22)
# make all the text red
ggplot(mtcars, aes(mpg, hp)) +
geom_point(aes(fill = gear)) +
easy_all_text_color("red")
# remove just x axis
ggplot(mtcars, aes(wt, mpg)) +
geom_point() +
easy_remove_x_axis()
# remove y axis ticks
ggplot(mtcars, aes(wt, mpg)) +
geom_point() +
easy_remove_y_axis(what = "ticks")
# move legends to bottom
ggplot(mtcars, aes(wt, mpg, colour = cyl, size = hp)) +
geom_point() +
easy_move_legend("bottom")
# move legend to left side
ggplot(mtcars, aes(wt, mpg, colour = cyl, size = hp)) +
geom_point() +
easy_legend_at("left")
# Make legends horizontal
ggplot(mtcars, aes(wt, mpg, colour = cyl, size = hp)) +
geom_point() + easy_rotate_legend("horizontal")
# use labelled variables
iris_labs <- iris
labelled::var_label(iris_labs$Species) <- "Flower\nSpecies"
labelled::var_label(iris_labs$Sepal.Length) <- "Length of Sepal"
iris_labs_2 <- iris_labs
labelled::var_label(iris_labs_2$Species) <- "Sub-genera"
# use variable labels automatically
ggplot(iris_labs, aes(x = Sepal.Length, y = Sepal.Width)) +
geom_line(aes(colour = Species)) +
geom_point(data = iris_labs_2, aes(fill = Species), shape = 24) +
easy_labs()
```
These functions will try to teach you the 'official' way to achieve these goal,
usually via the `teach` argument (where implemented)
```{r teach}
ggplot(mtcars, aes(hp, mpg)) +
geom_point() +
easy_rotate_y_labels(angle = "startatbottom", teach = TRUE)
ggplot(mtcars, aes(wt, mpg)) +
geom_point() +
easy_remove_y_axis(what = "ticks", teach = TRUE)
```
## Credits
Many thanks to [Sébastien Rochette (\@statnmap)](https://statnmap.com/) for
the design and execution of the hex logo.