8 meme
Of course, the plot and panel background fill should still be transparent or semi-transparent if oc-
cupying a large amount of the total meme plot area or it will obscure the meme image itself. An
alternative is to use inset as, for example, a tiny thumbnail in the corner of the meme plot, in which
case full opacity is not necessarily an issue. If you do not want to override the theme of your plot
and do not wish to pass a theme explicitly by ggtheme, you can set ggtheme = NULL
Dimensions and image processing
Specifying width and height is not required. By default, output file dimensions are taken from the
input file, img. However, these arguments can be used to override the default dimension matching.
The aspect ratio is fixed so if you change the two disproportionately, you will increasing the canvas,
adding bars on two sides; it will not stretch the image.
mult can be set less than one if relying on img dimension for meme plot width and height and img
is large. It is equivalent to scaling proportionately with width and height maintaining the original
aspect ratio. Whether or not width and/or height are provided, mult is always applied (defaults to
mult = 1).
Beyond this basic resizing to help control output file size, it is not the intent of memery to offer
general image processing capabilities. If adjustments to source images are desired, you should use
a dedicated package for image processing. magick is recommended.
Reading and writing gifs
Reading and writing gifs requires the magick package. Since this is not required for any other
part of memery and it represents a minor use case, the package does not have these dependencies.
magick is listed as a suggested package for memery; it is not imported as a dependency. meme_gif
is an optional extra function. In order to use it, install the magick package.
See the example below if your system meets these requirements. As with jpg or png image inputs,
if additional control is required for making custom adjustments to gif image frames, use the magick
package for image pre-processing. meme only provides basic control over output size and meme_gif
only adds control over gif frame selection and rate.
Examples
# Prepare data and make a graph
library(ggplot2)
x <- seq(0, 2*pi, length.out = 50)
panels <- rep(c("Plot A", "Plot B"), each = 50)
d <- data.frame(x = x, y = sin(x), grp = panels)
txt <- c("Philosoraptor's plots", "I like to make plots",
"Figure 1. (A) shows a plot and (B) shows another plot.")
out <- tempfile("meme", fileext = c("1.png", "2.png", "3.png", "4.gif"))
p <- ggplot(d, aes(x, y)) + geom_line(colour = "cornflowerblue", size = 2) +
geom_point(colour = "orange", size = 4) + facet_wrap(~grp) +
labs(title = txt[1], subtitle = txt[2], caption = txt[3])
# meme image background and text labels
img <- system.file("philosoraptor.jpg", package = "memery")
lab <- c("Title meme text", "Subtitle text")