| name | hex-logo |
| description | Create professional hexagonal package logos using hexSticker with Google Fonts, proper dimensions, and automated generation scripts |
Hexagonal Package Logo Creation
This skill covers creating professional hexagonal package logos using the hexSticker package. Hex logos are the standard branding for R packages, featured on package websites, GitHub repos, and CRAN pages.
Rules
- Standard dimensions: 5.08cm x 4.39cm (2 x 1.73 inches) for consistency
- Use hexSticker package for proper proportions and formatting
- Generate with script in man/figures/generate_logo.R (reproducible)
- Exclude script from build via .Rbuildignore
- Output both PNG and SVG formats (PNG for README, SVG for print)
- Use Google Fonts with showtext for custom typography
- Match package identity with appropriate colors and imagery
- Keep it simple - logos should work at small sizes
- Add to README with proper alignment and alt text
- Version control logos (commit PNG/SVG, not temporary files)
Installation and Setup
Required Packages
install.packages("hexSticker")
install.packages("showtext")
install.packages("ggplot2")
install.packages("magick")
library(hexSticker)
library(showtext)
library(ggplot2)
Standard Hex Dimensions
Official Specifications
- Width: 5.08 cm (2 inches)
- Height: 4.39 cm (1.73 inches)
- Aspect ratio: ~1.15:1
- DPI: 300 for print, 72 for web (hexSticker uses default appropriate for each)
These are set automatically by hexSticker.
Basic Hex Sticker Creation
Minimal Example (Text Only)
library(hexSticker)
sticker(
subplot = ~ plot.new(),
package = "mypackage",
p_size = 20,
p_color = "#FFFFFF",
h_fill = "#0054AD",
h_color = "#000000",
filename = "man/figures/logo.png"
)
With Image Subplot
library(hexSticker)
img_path <- "man/figures/icon.png"
sticker(
subplot = img_path,
s_x = 1,
s_y = 0.75,
s_width = 0.6,
s_height = 0.6,
package = "mypackage",
p_size = 20,
p_y = 1.45,
p_color = "#FFFFFF",
h_fill = "#0054AD",
h_color = "#000000",
filename = "man/figures/logo.png"
)
With ggplot2 Subplot
library(hexSticker)
library(ggplot2)
p <- ggplot(mtcars, aes(mpg, wt)) +
geom_point(color = "white", size = 2) +
theme_void() +
theme_transparent()
sticker(
subplot = p,
s_x = 1,
s_y = 0.85,
s_width = 1.3,
s_height = 1,
package = "mypackage",
p_size = 20,
p_y = 1.5,
p_color = "#FFFFFF",
h_fill = "#0054AD",
h_color = "#FFFFFF",
h_size = 1.5,
filename = "man/figures/logo.png",
dpi = 300
)
Google Fonts Integration
Using showtext for Custom Fonts
library(hexSticker)
library(showtext)
font_add_google("Fira Sans", "firasans")
font_add_google("Fira Code", "firacode")
showtext_auto()
sticker(
subplot = ~ plot.new(),
package = "mypackage",
p_size = 24,
p_family = "firasans",
p_fontface = "bold",
p_color = "#FFFFFF",
h_fill = "#0054AD",
h_color = "#000000",
filename = "man/figures/logo.png",
dpi = 300
)
Popular Font Combinations
font_add_google("Inter", "inter")
font_add_google("JetBrains Mono", "jetbrains")
font_add_google("Roboto", "roboto")
font_add_google("Roboto Slab", "robotoslab")
font_add_google("Nunito", "nunito")
font_add_google("Quicksand", "quicksand")
font_add_google("Fira Sans", "firasans")
font_add_google("Fira Code", "firacode")
font_add_google("Lato", "lato")
font_add_google("Merriweather", "merriweather")
font_add_google("Montserrat", "montserrat")
font_add_google("Bebas Neue", "bebas")
Complete Generation Script Template
man/figures/generate_logo.R
library(hexSticker)
library(showtext)
library(ggplot2)
PACKAGE_NAME <- "mypackage"
OUTPUT_DIR <- "man/figures"
if (!dir.exists(OUTPUT_DIR)) {
dir.create(OUTPUT_DIR, recursive = TRUE)
}
font_add_google("Fira Sans", "firasans")
showtext_auto()
FILL_COLOR <- "#0054AD"
BORDER_COLOR <- "#000000"
TEXT_COLOR <- "#FFFFFF"
ACCENT_COLOR <- "#FFA500"
set.seed(123)
plot_data <- data.frame(
x = rnorm(100),
y = rnorm(100)
)
p <- ggplot(plot_data, aes(x, y)) +
geom_point(color = TEXT_COLOR, alpha = 0.6, size = 1.5) +
geom_density_2d(color = ACCENT_COLOR, size = 0.8) +
theme_void() +
theme_transparent() +
theme(
legend.position = "none",
panel.background = element_rect(fill = "transparent", color = NA),
plot.background = element_rect(fill = "transparent", color = NA)
)
sticker(
subplot = p,
s_x = 1,
s_y = 0.85,
s_width = 1.4,
s_height = 1.1,
package = PACKAGE_NAME,
p_size = 20,
p_family = "firasans",
p_fontface = "bold",
p_color = TEXT_COLOR,
p_y = 1.5,
h_fill = FILL_COLOR,
h_color = BORDER_COLOR,
h_size = 1.5,
url = "github.com/username/mypackage",
u_size = 3.5,
u_color = TEXT_COLOR,
u_family = "firasans",
filename = file.path(OUTPUT_DIR, "logo.png"),
dpi = 300
)
sticker(
subplot = p,
s_x = 1,
s_y = 0.85,
s_width = 1.4,
s_height = 1.1,
package = PACKAGE_NAME,
p_size = 20,
p_family = "firasans",
p_fontface = "bold",
p_color = TEXT_COLOR,
p_y = 1.5,
h_fill = FILL_COLOR,
h_color = BORDER_COLOR,
h_size = 1.5,
url = "github.com/username/mypackage",
u_size = 3.5,
u_color = TEXT_COLOR,
u_family = "firasans",
filename = file.path(OUTPUT_DIR, "logo.svg")
)
message("Logo generated successfully:")
message(" PNG: ", file.path(OUTPUT_DIR, "logo.png"))
message(" SVG: ", file.path(OUTPUT_DIR, "logo.svg"))
Make Script Executable
chmod +x man/figures/generate_logo.R
Exclude from Package Build
Add to .Rbuildignore:
^man/figures/generate_logo\.R$
Or use usethis:
usethis::use_build_ignore("man/figures/generate_logo.R")
Comprehensive Parameter Reference
sticker() Parameters
Subplot Parameters
- subplot: Image path, ggplot object, or expression (required)
- s_x: Horizontal position (default: 1, center)
- s_y: Vertical position (default: 0.75)
- s_width: Width scaling (default: 0.4)
- s_height: Height scaling (default: 0.4)
Package Name Parameters
- package: Package name string
- p_x: Horizontal position (default: 1, center)
- p_y: Vertical position (default: 1.4, bottom)
- p_size: Font size (default: 8)
- p_color: Text color (default: "#FFFFFF")
- p_family: Font family (default: "sans")
- p_fontface: Font face: "plain", "bold", "italic", "bold.italic"
Hex Parameters
- h_fill: Fill color (default: "#1881C2")
- h_color: Border color (default: "#87B13F")
- h_size: Border width (default: 1.2)
Spotlight/White Space Parameters
- spotlight: Add spotlight effect (default: FALSE)
- l_x: Spotlight horizontal position
- l_y: Spotlight vertical position
- l_width: Spotlight width
- l_height: Spotlight height
- l_alpha: Spotlight transparency (0-1)
URL Parameters
- url: URL text to display at bottom
- u_x: URL horizontal position (default: 1)
- u_y: URL vertical position (default: 0.08)
- u_size: URL font size (default: 1.5)
- u_color: URL text color (default: "black")
- u_family: URL font family
- u_angle: URL text angle (default: 30)
Output Parameters
- filename: Output file path (required)
- dpi: Resolution for PNG (default: 300)
- asp: Aspect ratio override (usually omit)
Color Scheme Guidelines
Choosing Colors
Brand colors: Match your organization/project colors
Contrast: Ensure text is readable on background
Color theory:
- Complementary: Opposite on color wheel (high contrast)
- Analogous: Adjacent on color wheel (harmonious)
- Triadic: Three evenly spaced colors (balanced)
Color Palette Examples
h_fill = "#1881C2"
h_color = "#87B13F"
p_color = "#FFFFFF"
h_fill = "#0054AD"
h_color = "#003366"
p_color = "#FFFFFF"
h_fill = "#DC3545"
h_color = "#8B0000"
p_color = "#FFFFFF"