gglgbtq
June 25, 2024 · View on GitHub
gglgbtq provides multiple palettes based on flags in LGBTQ community. These palettes are accompanied by ggplot2 themes that maximize readability of each palette (especially of the white strip that is present in most flags).
Installation
# Install the development version from GitHub:
# install.packages("devtools")
devtools::install_github("turtletopia/gglgbtq")
User guide
To list all available palettes, call:
``$ \text{r} \text{show_pride}()
# \text{A} \text{tibble}: 41 \times 2
\text{palettes} \text{lengths}
<\text{chr}> <\text{int}>
1 \text{rainbow} 6
2 \text{lesbian} 5
3 \text{gay} 5
4 \text{bisexual} 3
5 \text{transgender} 3
6 \text{asexual} 4
7 \text{intersex} 2
8 \text{nonbinary} 4
9 \text{philadelphia} 8
10 \text{progress} 11
# ℹ 31 \text{more} \text{rows}
$``
The most common use case is to use palettes with ggplot2:
library(ggplot2)
data <- data.frame(
group = rep(c("yes", "no", "maybe"), each = 3) |>
as.factor(),
x = rep(seq_len(3), times = 3),
y = runif(3 * 3) + .5
)
ggplot(data, aes(x = x, y = y, fill = group)) +
geom_bar(stat = "identity", position = "dodge") +
scale_fill_lgbtq("pansexual")

Use matching theme_lgbtq() to make colors stand out the most:
ggplot(data, aes(x = x, y = y, fill = group)) +
geom_bar(stat = "identity", position = "dodge") +
scale_fill_lgbtq("pansexual") +
theme_lgbtq("pansexual")

theme_lgbtq() passes additional parameters to ggplot2::theme(), so
it’s fully customizable:
ggplot(data, aes(x = x, y = y, fill = group)) +
geom_bar(stat = "identity", position = "dodge") +
scale_fill_lgbtq("pansexual") +
theme_lgbtq("pansexual", legend.position = "left")

Almost all ggplot2 uses of palette_lgbtq() will be with color and
fill scales, so the scale_color_lgbtq() and scale_fill_lgbtq()
functions provide a shorthand and more descriptive notation; there’s
nothing stopping you, however, from passing them manually or using in
any other package, though the ggplot2 dependency might be a pretty large
one.
ggplot(data, aes(x = x, y = y, fill = group)) +
geom_bar(stat = "identity", position = "dodge") +
scale_fill_manual(values = palette_lgbtq("pansexual")) +
theme_lgbtq("pansexual", legend.position = "left")

Gallery
Only a few most common palettes are included below. For the complete list, see palette gallery vignette.
palette_lgbtq("rainbow")

palette_lgbtq("philadelphia")

palette_lgbtq("progress")

palette_lgbtq("lesbian")

# In its original meaning of "gay men"
palette_lgbtq("gay")

palette_lgbtq("bisexual")

# Background added to avoid the "disappearance" of the white stripe
print(palette_lgbtq("transgender"), background = "gray92")

palette_lgbtq("asexual")

palette_lgbtq("nonbinary")

palette_lgbtq("intersex")

End notes
I believe in equal rights and treatment for everybody, regardless of their sexuality, gender identity, skin tone, nationality, and other features beyond human control. Thus, I do not allow gglgbtq to be used in any project that promotes hate based on the aforementioned factors.