This function creates a formatted caption with social media icons and usernames that can be easily added to ggplot2 charts for personal branding.
Usage
branding(
github = NULL,
gitlab = NULL,
linkedin = NULL,
bluesky = NULL,
twitter = NULL,
mastodon = NULL,
orcid = NULL,
email = NULL,
website = NULL,
custom_icons = NULL,
additional_text = NULL,
text_position = "before",
line_spacing = 1L,
icon_color = "#666666",
text_color = "#333333",
icon_size = "8pt",
text_size = "8pt",
line_height = "1.2",
text_family = NULL,
additional_text_color = NULL,
additional_text_size = NULL,
setup_fonts = TRUE
)Arguments
- github
(
NULL | character(1)) GitHub username (optional)- gitlab
(
NULL | character(1)) GitLab username (optional)(
NULL | character(1)) LinkedIn username (optional)- bluesky
(
NULL | character(1)) Bluesky handle (optional)(
NULL | character(1)) Twitter/X handle (optional)- mastodon
(
NULL | character(1)) Mastodon handle (optional)- orcid
(
NULL | character(1)) ORCID ID (optional)(
NULL | character(1)) Email address (optional)- website
(
NULL | character(1)) Website URL (optional)- custom_icons
(
NULL | character) Named vector of additional icon names and usernames (optional). Names should match icons from icons_df.- additional_text
(
NULL | character(1)) Additional text to include in caption (e.g., "Data source: XYZ")- text_position
(
character(1)) Position of additional text relative to branding. Either "before" or "after". (default: "before")- line_spacing
(
integer(1)) Number of line breaks between additional text and icons (1-3). (default: 1)- icon_color
(
character(1)) Color for icons. (default is "#666666")- text_color
(
character(1)) Color for usernames/text. (default: "#333333")- icon_size
(
character(1)) Font size for icons. (default: "8pt")- text_size
(
character(1)) Font size for text/usernames. (default: "8pt")- line_height
(
character(1)) Line height for the caption. (default: "1.2")- text_family
(
NULL | character(1)) Font family for text/usernames. (default: NULL uses system default)- additional_text_color
(
NULL | character(1)) Color for additional text. If NULL, uses text_color. (default: NULL)- additional_text_size
(
NULL | character(1)) Font size for additional text. If NULL, uses text_size. (default: NULL)- setup_fonts
(
logical(1)) Whether to automatically setup Font Awesome fonts. (default: TRUE)
Examples
# \donttest{
library(ggplot2)
library(ggtext)
# Basic usage with GitHub and LinkedIn
caption <- branding(github = "yourusername", linkedin = "yourprofile")
ggplot(mtcars, aes(x = mpg, y = wt)) +
geom_point() +
labs(caption = caption) +
theme(plot.caption = ggtext::element_textbox_simple())
# With additional text and custom spacing
caption <- branding(
github = "yourusername",
linkedin = "yourprofile",
additional_text = "Data source: mtcars dataset",
text_position = "before",
line_spacing = 2L,
icon_color = "steelblue",
text_color = "steelblue"
)
# With custom icons from icons_df
caption <- branding(
github = "yourusername",
custom_icons = c(
envelope = "contact@example.com",
globe = "https://mywebsite.com",
rss = "myblog"
)
)
#> No icon found for platform 'rss', using generic link icon with following unicode: 'xf0c1'.
# }
