https://github.com/nacnudus/ggbillboard
Use vacant ggplot2 facets for advertising
https://github.com/nacnudus/ggbillboard
Last synced: 15 days ago
JSON representation
Use vacant ggplot2 facets for advertising
- Host: GitHub
- URL: https://github.com/nacnudus/ggbillboard
- Owner: nacnudus
- License: other
- Created: 2020-07-08T18:05:38.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2020-07-08T19:39:47.000Z (almost 5 years ago)
- Last Synced: 2025-04-01T18:23:43.775Z (about 1 month ago)
- Language: R
- Size: 644 KB
- Stars: 28
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.Rmd
- License: LICENSE
Awesome Lists containing this project
README
---
output: github_document
---```{r, include = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
comment = "#>",
fig.path = "man/figures/README-",
out.width = "100%"
)
```# ggbillboard
A package to fill vacant ggplot2 facets with images. You could advertise your
consultancy, for example.## Installation
You can install the development version of ggbillboard from [GitHub](https://github.com/nacnudus/ggbillboard) with:
``` r
# install.packages("remotes")
remotes::install_github("nacnudus/ggbillboard")
```## Example
This is a basic example which shows you how to solve a common problem:
```{r example}
library(ggbillboard)library(ggplot2)
library(png) # To load png image files
library(jpeg) # To load jpeg image filesimg1 <- readPNG(system.file("img", "Rlogo.png", package="ggbillboard"))
img2 <- readJPEG(system.file("img", "spongebob.png", package="ggbillboard"))# Images must be converted to grobs.
g1 <- grid::rasterGrob(img1, interpolate=TRUE)
g2 <- grid::rasterGrob(img2, interpolate=TRUE)# Create a plot
p1 <-
ggplot(economics_long, aes(date, value)) +
geom_line() +
facet_wrap(vars(variable), scales = "free_y", nrow = 2)# Fill the vacant facet with an image
billboard(p1, g1)# If multiple facets are vacant, you can use more than one image, and they will
# be recycled to fill all vacant facets.
p2 <-
ggplot(ChickWeight, aes(Time, weight)) +
geom_point() +
facet_wrap(~ Diet, ncol = 3)billboard(p2, list(g1, g2))
billboard(p2, g1)
```