require("ggconventions")
# create gender convention function
as_convention_gender <- function(x) {
y = factor(toupper(x), levels=c("MALE", "FEMALE"))
class(y) <- c("convention", class(y))
attr(y, "convention") <- "gender"
y
}
as_convention_sex <- as_convention_gender
# create scales for our conventions
scale_colour_gender <- function(...) {
scale_colour_manual(...,
values=c("FEMALE"="deeppink1", "MALE"="blue"))
}
scale_fill_gender <- function(...) {
scale_fill_manual(...,
values=c("FEMALE"="deeppink1", "MALE"="blue"))
}
scale_shape_gender <- function(...) {
convention <- getOption("gender_shape", "default")
switch(convention,
bathroom = scale_shape_manual(...,
values=c("FEMALE"="\U0001f6ba", "MALE"="\U0001f6b9")),
emoji = scale_shape_manual(...,
values=c("FEMALE"="\U0001f469", "MALE"="\U0001f468")),
scale_shape_manual(...,
values=c("FEMALE"="\u2640", "MALE"="\u2642"))
)
}
scale_x_gender <- function(...) { scale_x_discrete(...) }
scale_y_gender <- function(...) { scale_y_discrete(...) }
scale_linetype_gender <- function(...) { scale_linetype_discrete(...) }
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.