Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/R-CoderDotCom/ggcats

The geom you always wished for adding cats to ggplot2
https://github.com/R-CoderDotCom/ggcats

ggplot-extension ggplot2 rstats rstats-package

Last synced: 3 days ago
JSON representation

The geom you always wished for adding cats to ggplot2

Awesome Lists containing this project

README

        

# ggcats
The geom you always wished for adding cats to ggplot2. This package is part of the memeverse.
The source code of this package is based on geom_image from ggimage.



+ Follow me on [Twitter](https://twitter.com/RCoderWeb)
+ Follow me on [Facebook](https://www.facebook.com/RCODERweb)
+ Visit my [R programming site](https://r-coder.com/)

## What is the memeverse?

A collection of funny packages which can be interesting to create plots to show on a first lesson to new R students in order to motivate them learning the language. The other package of the (small) memeverse are [ggdogs](https://github.com/R-CoderDotCom/ggdogs) and [ggbernie](https://github.com/R-CoderDotCom/ggbernie). Statistics and programming can be fun!

## Installation
```r
# install.packages("remotes")
remotes::install_github("R-CoderDotCom/ggcats@main")
```

## Available cats

There are 15 cats available:

```r
"nyancat" (default), "bongo", "colonel", "grumpy", "hipster", "lil_bub", "maru",
"mouth", "pop", "pop_close", "pusheen", "pusheen_pc", "toast", "venus" and "shironeko"
```

## Some examples

```r
grid <- expand.grid(1:5, 3:1)

df <- data.frame(x = grid[, 1],
y = grid[, 2],
image = c("nyancat", "bongo", "colonel", "grumpy", "hipster",
"lil_bub", "maru", "mouth", "pop", "pop_close",
"pusheen", "pusheen_pc", "toast", "venus", "shironeko"))

library(ggplot2)
ggplot(df) +
geom_cat(aes(x, y, cat = image), size = 5) +
xlim(c(0.25, 5.5)) +
ylim(c(0.25, 3.5))
```



```r
ggplot(mtcars) +
geom_cat(aes(mpg, wt), cat = "nyancat", size = 5)
```



```r
ggplot(mtcars) +
geom_cat(aes(mpg, wt, size = cyl), cat = "toast")
```



I took the most part of the following code from [Jonathan Hersh](https://twitter.com/DogmaticPrior).

```r
library(Ecdat)
data(incomeInequality)

library(tidyverse)
library(ggcats)
library(gganimate)

dat <-
incomeInequality %>%
select(Year, P99, median) %>%
rename(income_median = median,
income_99percent = P99) %>%
pivot_longer(cols = starts_with("income"),
names_to = "income",
names_prefix = "income_")

dat$cat <- rep(NA, 132)

dat$cat[which(dat$income == "median")] <- "nyancat"
dat$cat[which(dat$income == "99percent")] <- rep(c("pop_close", "pop"), 33)

ggplot(dat, aes(x = Year, y = value, group = income, color = income)) +
geom_line(size = 2) +
ggtitle("ggcats, a core package of the memeverse") +
geom_cat(aes(cat = cat), size = 5) +
xlab("Cats") +
ylab("Cats") +
theme(legend.position = "none",
plot.title = element_text(size = 20),
axis.text = element_blank(),
axis.ticks = element_blank()) +
transition_reveal(Year)
```