Skip to content
/ ggameboy Public

A package to plot and save customly colored gameboy pictures based on ggplot2

License

Notifications You must be signed in to change notification settings

toebR/ggameboy

Repository files navigation

ggameboy

This package lets you plot & save customly colored gameboys based on ggplot2.

1. Installation

To use this package, you'll need to have the following packages installed:

install.packages(c("ggplot2", "statebins", "extrafont")) #run once
extrafont::register_fonts() #run once
extrafont::loadfonts(quiet = TRUE) #run once in every new R session

The package can be installed via:

devtools::install_github("toebR/ggameboy")
library(gameboy)

2. Description

The package use is fairly easy.
The following function plots a default monochrome gameboy:

gameboy_plot() -> test
test

The plot can be saved in your working directory with an optimised width:height ratio with a simple export function:

save_gameboy_png(plotvar = test, dpi = 300, name = "test_export") #default parameters which can be changed

testexport

2.1 Parameters

The gameboy_plot() function allows you to change EVERY color of almost all elements of the gameboy as well as the screen text.
The following infographic shows which parameters change what element of the plot:

info_gb

2.2 Example

Once the parameters are clear, it's easy to change some element and make your custom gameboy:

gameboy_plot(background = "white", case = "green", screentext = "Custom Gameboy") 

testexport

3. Compatibility with ggplot2 & extensions

3.1 ggplot2

Since the gameboy is basically a ggplot2 plot, you can add a title etc. to your pleasing.

P <- gameboy_plot(background = "grey", case = "darkblue", screentext = "I played Pokémon on this one")

P + ggtitle("This is a title") +
  labs(caption = "This is a caption")

blue_test

3.2 Patchwork

Lets say you want to arrange some of your gameboys into one plot.I did this easily with patchwork:
The gameboys have a bit of a different width:height ration but you get the idea.

library(patchwork)

(gameboy_monochrome + gameboy_turquoise)/(gameboy_green + gameboy_red) / (gameboy_yellow + gameboy_purple) -> patch

patch + plot_annotation(title = "\nWHAT WE CAN DO WITH {GGPLOT2}\n", caption = "Code & Design by Tobias Stalder (@toeb18)",
  theme = theme(
  plot.background = element_rect(fill = "#293133", color = "#293133"),
  panel.background = element_rect(fill = "#E0E0E0", color = "#E0E0E0"),
  plot.title = element_text(size = 30, color = "white", family = "Consolas", hjust = .5),
  plot.caption = element_text(size = 10, color = "white", family = "Consolas", hjust = .5)
)) -> gameboy_poster

poster_gameboy

The "GAMEBOY" brand is under copyright from © 2021 Nintendo.

About

A package to plot and save customly colored gameboy pictures based on ggplot2

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages