Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/jonocarroll/ggeasy

ggplot2 shortcuts (transformations made easy)
https://github.com/jonocarroll/ggeasy

Last synced: about 1 month ago
JSON representation

ggplot2 shortcuts (transformations made easy)

Awesome Lists containing this project

README

        

---
output: github_document
always_allow_html: yes
---

```{r, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/"
)
```

# ggeasy

[![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)
[![Travis build status](https://travis-ci.org/jonocarroll/ggeasy.svg?branch=master)](https://travis-ci.org/jonocarroll/ggeasy)
[![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)

`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/author/Sharon-Machlis/) has a great [article](https://www.infoworld.com/article/3533453/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.