Source code used to generate Hex Stickers for my R packages, using hexSticker.
Requires imageMagick, run: brew install imagemagick
.
library(hexSticker)
library(showtext)
library(tidyr)
library(ggplot2)
library(jbplot)
I used https://github.com/ryansafner/hexstickers as a reference
to help get started with hexStickers.
rdev
Sticker for rdev.
Uses a modified version of the Wikimedia Commons Infinity
in circle symbol to represent DevOps. The
fill color is OSHA
safety yellow.
font_add_google("Lato")
# TODO: understand why setting dpi = 600 and not dpi = 1200 correctly sizes the font
showtext_opts(dpi = 600)
sticker(
"assets/infinity.png",
s_x = 1,
s_y = 0.7,
s_width = 0.5,
s_height = 0.5,
package = "rdev",
p_color = "black",
p_family = "Lato",
p_size = 28,
h_fill = "#EAC234",
h_color = "black",
filename = "rendered/rdev.png",
dpi = 1200
)
Rendered file:
jbplot
Sticker for jbplot.
First Version
The background of the sticker is a line plot with three colors using
the viridis color
map.
j_series <- c(1, 2, 3, 4, 5, 4, 5, 6, 7, 8)
jbplot_v1 <- data.frame(
observation = 1:10,
group_a = j_series - 1,
group_b = j_series + 1,
group_c = j_series + 3
) |>
pivot_longer(!observation, names_to = "group") |>
ggplot(aes(x = observation, y = value, color = group)) +
geom_line() +
geom_point() +
labs(x = NULL, y = NULL) +
guides(color = "none") +
scale_x_continuous(labels = NULL) +
scale_y_continuous(limits = c(-1, 12), labels = NULL) +
scale_color_viridis_d() +
theme_quo()
sticker(
jbplot_v1,
s_x = 1,
s_y = 1,
s_width = 2,
s_height = 2.15,
package = "jbplot",
p_color = "gray50",
p_family = "Lato",
p_size = 24,
h_fill = "white",
h_color = "black",
white_around_sticker = TRUE,
filename = "rendered/jbplot_v1.png",
dpi = 1200
)
Rendered file:
While this version is OK, it’s strangely unsatisfying.
Second Version
The second version uses a jbplot ggplot_donut()
plot with the viridis color map.
jbplot <- data.frame(group = c("A", "B", "C"), n = c(4, 3, 2), stringsAsFactors = FALSE) |>
ggplot_donut(hsize = 4) +
scale_fill_viridis_d() +
guides(fill = "none") +
theme_transparent() +
theme(plot.background = element_rect(linewidth = 0))
sticker(
jbplot,
s_x = 0.983,
s_y = 0.6,
s_width = 1.1,
s_height = 1.1,
package = "jbplot",
p_color = "gray25",
p_family = "Lato",
p_size = 22,
h_fill = "white",
h_color = "gray50",
filename = "rendered/jbplot.png",
dpi = 1200
)
Rendered file:
The second version is more satisfying.
cards
Sticker for cards. Uses ggplot2
text annotations with unicode
card suits. The background is Poker Green and
the border is Dark
Wood.
c_size <- 9
cards <- ggplot() +
annotate("text", x = 1, y = 0, label = "A\u2663", size = c_size) +
annotate("text", x = 2, y = 0, label = "A\u2666", size = c_size, color = "red") +
annotate("text", x = 3, y = 0, label = "A\u2665", size = c_size, color = "red") +
annotate("text", x = 4, y = 0, label = "A\u2660", size = c_size) +
annotate("text", x = 5, y = 0, label = "K\u2663", size = c_size) +
scale_x_continuous(limits = c(0.25, 5.75)) +
theme_void() +
theme_transparent()
sticker(
cards,
s_x = 1,
s_y = 0.65,
s_width = 2,
s_height = 2,
package = "cards",
p_y = 1.2,
p_color = "#FFFFFF",
p_family = "Lato",
p_size = 22,
h_fill = "#35654D",
h_color = "#855E42",
filename = "rendered/cards.png",
dpi = 1200
)
Rendered file:
quantrr
Sticker for quantrr. Features an
uppercase “Q” in the Metropolis
font, rendered as a .png
since Metropolis isn’t in Google
Fonts. Blue Q, orange text, with a dark gray border and light gray
background.
pal <- jbplot::differently_palettes$primary
sticker(
"assets/q-logo.png",
s_x = 1,
s_y = 1.3,
s_width = 0.5,
s_height = 0.5,
package = "quantrr",
p_y = 0.7,
p_color = pal[["orange"]],
p_family = "Lato",
p_size = 20,
h_fill = pal[["lightgray"]],
h_color = pal[["darkgray"]],
filename = "rendered/quantrr.png",
dpi = 1200
)
Rendered file:
stickers
Stickers image built with the hexwall
script.
Because hexwall()
uses a white background, the sticker
background is also white. The border and title are Royal Blue.
hexwall("analysis/rendered", sticker_row_size = 2)
sticker(
"assets/hexwall.png",
s_x = 1,
s_y = 0.625,
s_width = 0.4,
s_height = 0.4,
package = "stickers",
p_color = "#2B60DE",
p_family = "Lato",
p_size = 18,
h_fill = "white",
h_color = "#2B60DE",
filename = "rendered/stickers.png",
dpi = 1200
)
Rendered file:
LS0tCnRpdGxlOiBIZXggU3RpY2tlcnMKYXV0aG9yOiBKb2huIEJlbm5pbmdob2ZmCmRhdGU6ICcyMDIzLTAyLTAxJwpkYXRlLW1vZGlmaWVkOiAnMjAyNC0xMS0xNicKY2F0ZWdvcmllczogc3RpY2tlcnMKb3JkZXI6IDEwMQpvdXRwdXQ6CiAgaHRtbF9kb2N1bWVudDoKICAgIHRoZW1lOgogICAgICB2ZXJzaW9uOiA1CiAgICAgIHByZXNldDogYm9vdHN0cmFwCiAgICBjc3M6IGFzc2V0cy9leHRyYS5jc3MKICAgIHBhbmRvY19hcmdzOiAtLXNoaWZ0LWhlYWRpbmctbGV2ZWwtYnk9MQogICAgdG9jOiB5ZXMKICAgIHRvY19mbG9hdDoKICAgICAgY29sbGFwc2VkOiBubwogICAgICBzbW9vdGhfc2Nyb2xsOiBubwotLS0KClNvdXJjZSBjb2RlIHVzZWQgdG8gZ2VuZXJhdGUgSGV4IFN0aWNrZXJzIGZvciBteSBSIHBhY2thZ2VzLCB1c2luZyBbaGV4U3RpY2tlcl0oaHR0cHM6Ly9naXRodWIuY29tL0d1YW5nY2h1YW5nWXUvaGV4U3RpY2tlcikuCgpSZXF1aXJlcyBpbWFnZU1hZ2ljaywgcnVuOiBgYnJldyBpbnN0YWxsIGltYWdlbWFnaWNrYC4KCmBgYHtyIHNldHVwLCBtZXNzYWdlID0gRkFMU0UsIHdhcm5pbmcgPSBGQUxTRX0KbGlicmFyeShoZXhTdGlja2VyKQpsaWJyYXJ5KHNob3d0ZXh0KQpsaWJyYXJ5KHRpZHlyKQpsaWJyYXJ5KGdncGxvdDIpCmxpYnJhcnkoamJwbG90KQpgYGAKCkkgdXNlZCA8aHR0cHM6Ly9naXRodWIuY29tL3J5YW5zYWZuZXIvaGV4c3RpY2tlcnM+IGFzIGEgcmVmZXJlbm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