-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathREADME.Rmd
108 lines (83 loc) · 3.81 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
---
output: github_document
---
```{r opts, echo = FALSE}
knitr::opts_chunk$set(
collapse = TRUE,
fig.height = 1.6
)
library(gglgbtq)
options(gglgbtq_font_size = 1.7)
set.seed(7)
```
# gglgbtq <a href="https://turtletopia.github.io/gglgbtq/"><img src="man/figures/logo.svg" align="right" height="139" /></a>
<!-- badges: start -->
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)
[![CRAN status](https://www.r-pkg.org/badges/version/gglgbtq)](https://CRAN.R-project.org/package=gglgbtq)
[![R-CMD-check](https://github.com/turtletopia/gglgbtq/workflows/R-CMD-check/badge.svg)](https://github.com/turtletopia/gglgbtq/actions)
[![Codecov test coverage](https://codecov.io/gh/turtletopia/gglgbtq/branch/master/graph/badge.svg)](https://app.codecov.io/gh/turtletopia/gglgbtq?branch=master)
<!-- badges: end -->
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
```{r install, eval = FALSE}
# Install the development version from GitHub:
# install.packages("devtools")
devtools::install_github("turtletopia/gglgbtq")
```
## User guide
To list all available palettes, call:
```{r pride_head}
show_pride()
```
The most common use case is to use palettes with ggplot2:
```{r ggplot2, fig.height=3}
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:
```{r ggplot2_theme, fig.height=3}
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:
```{r ggplot2_theme_custom, fig.height=3}
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.
```{r ggplot2_scale, fig.height=3}
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](https://turtletopia.github.io/gglgbtq/articles/gallery.html).
```{r palettes}
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.