@ -0,0 +1,62 @@ |
|||||
|
#' Preview numbers, kerning, and ligatures from font variants you create |
||||
|
#' |
||||
|
#' Use this function to preview the special features of fonts you create |
||||
|
#' including how well the default kerning ruls work, how tabular numbers |
||||
|
#' behave, and whether or not modern, fun ligatures are supported. Change |
||||
|
#' the `test_label` if you wish to use a custom preview string. |
||||
|
#' |
||||
|
#' @param font_variant a font variant object created with [reconfigure_font()] |
||||
|
#' @param font_size passed to [ggplot2::geom_text()] |
||||
|
#' @param test_label a specially designed preview string to showcase some |
||||
|
#' specific font features |
||||
|
#' @return A ggplot2 object |
||||
|
#' @export |
||||
|
#' @examples |
||||
|
#' reconfigure_font( |
||||
|
#' family = "Trattatello", |
||||
|
#' width = "normal", |
||||
|
#' ligatures = "discretionary", |
||||
|
#' calt = 1, tnum = 1, case = 1, |
||||
|
#' dlig = 1, kern = 1, |
||||
|
#' zero = 0, salt = 0 |
||||
|
#' ) -> trat |
||||
|
#' |
||||
|
#' preview_variant(trat) |
||||
|
#' |
||||
|
#' reconfigure_font( |
||||
|
#' family = "Barlow", |
||||
|
#' width = "normal", |
||||
|
#' ligatures = "standard", |
||||
|
#' tnum = 1, kern = 1 |
||||
|
#' ) -> barlow |
||||
|
#' |
||||
|
#' preview_variant(barlow) |
||||
|
preview_variant <- function(font_variant, font_size = 5, |
||||
|
test_label = "Lorem Ipsum dolor sit amet consectetur. => A⃝\n−0+1:2~3,456789\n−9+8:7~6,543210") { |
||||
|
|
||||
|
ggplot() + |
||||
|
geom_text( |
||||
|
data = data.frame( |
||||
|
x = rep(1, length(font_variant)), |
||||
|
y = 2 * (0:(length(font_variant)-1)), |
||||
|
family = unlist(font_variant, use.names = FALSE) |
||||
|
), |
||||
|
aes(x = x, y = y, label = test_label, family = family), |
||||
|
size = font_size, lineheight = 0.875, color = "black" |
||||
|
) + |
||||
|
scale_y_continuous(expand = c(0, 2)) + |
||||
|
labs(title = attr(font_variant, "family")) + |
||||
|
theme_minimal() + |
||||
|
theme( |
||||
|
plot.title = element_text(family = font_variant$normal, size = 9, hjust = 0.5) |
||||
|
) + |
||||
|
theme( |
||||
|
panel.grid.major = element_blank(), |
||||
|
panel.grid.minor = element_blank() |
||||
|
) + |
||||
|
theme( |
||||
|
axis.text = element_blank(), |
||||
|
axis.title = element_blank() |
||||
|
) |
||||
|
|
||||
|
} |
@ -0,0 +1,95 @@ |
|||||
|
list(Geom = structure(list(), .Names = character(0), class = "uneval"), |
||||
|
GeomAbline = structure(list(colour = "black", size = 0.5, |
||||
|
linetype = 1, alpha = NA), class = "uneval"), GeomAnnotationMap = structure(list( |
||||
|
colour = "NA", fill = "grey20", size = 0.5, linetype = 1, |
||||
|
alpha = NA, subgroup = NULL), class = "uneval"), GeomArea = structure(list( |
||||
|
colour = NA, fill = "grey20", size = 0.5, linetype = 1, |
||||
|
alpha = NA), class = "uneval"), GeomBar = structure(list( |
||||
|
colour = NA, fill = "grey35", size = 0.5, linetype = 1, |
||||
|
alpha = NA), class = "uneval"), GeomBlank = structure(list(), .Names = character(0), class = "uneval"), |
||||
|
GeomBoxplot = structure(list(weight = 1, colour = "grey20", |
||||
|
fill = "white", size = 0.5, alpha = NA, shape = 19, linetype = "solid"), class = "uneval"), |
||||
|
GeomCol = structure(list(colour = NA, fill = "grey35", size = 0.5, |
||||
|
linetype = 1, alpha = NA), class = "uneval"), GeomContour = structure(list( |
||||
|
weight = 1, colour = "#3366FF", size = 0.5, linetype = 1, |
||||
|
alpha = NA), class = "uneval"), GeomContourFilled = structure(list( |
||||
|
colour = "NA", fill = "grey20", size = 0.5, linetype = 1, |
||||
|
alpha = NA, subgroup = NULL), class = "uneval"), GeomCrossbar = structure(list( |
||||
|
colour = "black", fill = NA, size = 0.5, linetype = 1, |
||||
|
alpha = NA), class = "uneval"), GeomCurve = structure(list( |
||||
|
colour = "black", size = 0.5, linetype = 1, alpha = NA), class = "uneval"), |
||||
|
GeomCustomAnn = structure(list(xmin = -Inf, xmax = Inf, ymin = -Inf, |
||||
|
ymax = Inf), class = "uneval"), GeomDensity = list(fill = NA, |
||||
|
weight = 1, colour = "black", alpha = NA, size = 0.5, |
||||
|
linetype = 1), GeomDensity2d = structure(list(colour = "#3366FF", |
||||
|
size = 0.5, linetype = 1, alpha = NA), class = "uneval"), |
||||
|
GeomDensity2dFilled = structure(list(colour = "NA", fill = "grey20", |
||||
|
size = 0.5, linetype = 1, alpha = NA, subgroup = NULL), class = "uneval"), |
||||
|
GeomDotplot = structure(list(colour = "black", fill = "black", |
||||
|
alpha = NA, stroke = 1, linetype = "solid"), class = "uneval"), |
||||
|
GeomErrorbar = structure(list(colour = "black", size = 0.5, |
||||
|
linetype = 1, width = 0.5, alpha = NA), class = "uneval"), |
||||
|
GeomErrorbarh = structure(list(colour = "black", size = 0.5, |
||||
|
linetype = 1, height = 0.5, alpha = NA), class = "uneval"), |
||||
|
GeomFunction = structure(list(colour = "black", size = 0.5, |
||||
|
linetype = 1, alpha = NA), class = "uneval"), GeomHex = structure(list( |
||||
|
colour = NA, fill = "grey50", size = 0.5, linetype = 1, |
||||
|
alpha = NA), class = "uneval"), GeomHline = structure(list( |
||||
|
colour = "black", size = 0.5, linetype = 1, alpha = NA), class = "uneval"), |
||||
|
GeomLabel = structure(list(colour = "black", fill = "white", |
||||
|
size = 3.88, angle = 0, hjust = 0.5, vjust = 0.5, alpha = NA, |
||||
|
family = "", fontface = 1, lineheight = 1.2), class = "uneval"), |
||||
|
GeomLine = structure(list(colour = "black", size = 0.5, linetype = 1, |
||||
|
alpha = NA), class = "uneval"), GeomLinerange = structure(list( |
||||
|
colour = "black", size = 0.5, linetype = 1, alpha = NA), class = "uneval"), |
||||
|
GeomLogticks = structure(list(colour = "black", size = 0.5, |
||||
|
linetype = 1, alpha = 1), class = "uneval"), GeomMap = structure(list( |
||||
|
colour = "NA", fill = "grey20", size = 0.5, linetype = 1, |
||||
|
alpha = NA, subgroup = NULL), class = "uneval"), GeomPath = structure(list( |
||||
|
colour = "black", size = 0.5, linetype = 1, alpha = NA), class = "uneval"), |
||||
|
GeomPoint = structure(list(shape = 19, colour = "black", |
||||
|
size = 1.5, fill = NA, alpha = NA, stroke = 0.5), class = "uneval"), |
||||
|
GeomPointrange = structure(list(colour = "black", size = 0.5, |
||||
|
linetype = 1, shape = 19, fill = NA, alpha = NA, stroke = 1), class = "uneval"), |
||||
|
GeomPolygon = structure(list(colour = "NA", fill = "grey20", |
||||
|
size = 0.5, linetype = 1, alpha = NA, subgroup = NULL), class = "uneval"), |
||||
|
GeomQuantile = list(weight = 1, colour = "#3366FF", size = 0.5, |
||||
|
linetype = 1, alpha = NA), GeomRaster = structure(list( |
||||
|
fill = "grey20", alpha = NA), class = "uneval"), GeomRasterAnn = structure(list(), |
||||
|
.Names = character(0), class = "uneval"), |
||||
|
GeomRect = structure(list(colour = NA, fill = "grey35", size = 0.5, |
||||
|
linetype = 1, alpha = NA), class = "uneval"), GeomRibbon = structure(list( |
||||
|
colour = NA, fill = "grey20", size = 0.5, linetype = 1, |
||||
|
alpha = NA), class = "uneval"), GeomRug = structure(list( |
||||
|
colour = "black", size = 0.5, linetype = 1, alpha = NA), class = "uneval"), |
||||
|
GeomSegment = structure(list(colour = "black", size = 0.5, |
||||
|
linetype = 1, alpha = NA), class = "uneval"), GeomSf = structure(list( |
||||
|
shape = NULL, colour = NULL, fill = NULL, size = NULL, |
||||
|
linetype = 1, alpha = NA, stroke = 0.5), class = "uneval"), |
||||
|
GeomSmooth = structure(list(colour = "#3366FF", fill = "grey60", |
||||
|
size = 1, linetype = 1, weight = 1, alpha = 0.4), class = "uneval"), |
||||
|
GeomSpoke = structure(list(colour = "black", size = 0.5, |
||||
|
linetype = 1, alpha = NA), class = "uneval"), GeomStep = structure(list( |
||||
|
colour = "black", size = 0.5, linetype = 1, alpha = NA), class = "uneval"), |
||||
|
GeomText = structure(list(colour = "black", size = 3.88, |
||||
|
angle = 0, hjust = 0.5, vjust = 0.5, alpha = NA, family = "", |
||||
|
fontface = 1, lineheight = 1.2), class = "uneval"), GeomTile = structure(list( |
||||
|
fill = "grey20", colour = NA, size = 0.1, linetype = 1, |
||||
|
alpha = NA, width = NA, height = NA), class = "uneval"), |
||||
|
GeomViolin = structure(list(weight = 1, colour = "grey20", |
||||
|
fill = "white", size = 0.5, alpha = NA, linetype = "solid"), class = "uneval"), |
||||
|
GeomVline = structure(list(colour = "black", size = 0.5, |
||||
|
linetype = 1, alpha = NA), class = "uneval")) -> .ggplot2_default_aes |
||||
|
|
||||
|
#' Restore all ggplot2 geom to default aesthetics |
||||
|
#' |
||||
|
#' @export |
||||
|
reset_ggplot2_defaults <- function() { |
||||
|
|
||||
|
for (geom in names(.ggplot2_default_aes)) { |
||||
|
ggplot2::update_geom_defaults( |
||||
|
geom = get(geom), .ggplot2_default_aes[[geom]] |
||||
|
) |
||||
|
} |
||||
|
|
||||
|
} |
@ -1,278 +0,0 @@ |
|||||
# #' ggplot2 Theme Based On The Roboto Condensed Font Family |
|
||||
# #' |
|
||||
# #' Uses the built-in [roboto_pkg] custom font. |
|
||||
# #' |
|
||||
# #' - `background_colour` dark mode is "`#121212`" else "`white`" |
|
||||
# #' - `foreground_colour` dark mode is "`#e1e1e1`" else "`#262626`" |
|
||||
# #' - `grid_col` dark mode is "`#606367`" else "`#cccccc`" |
|
||||
# #' - `axis_col` dark mode is "`#606367`" else "`#2b2b2b`" |
|
||||
# #' |
|
||||
# #' @note this function updates `Geom` defaults |
|
||||
# #' @param base_size base font size |
|
||||
# #' @param line_height default line height |
|
||||
# #' @param plot_title_size plot title size |
|
||||
# #' @param plot_title_position plot title position |
|
||||
# #' @param plot_title_margin plot title margin |
|
||||
# #' @param subtitle_size subtitle size |
|
||||
# #' @param subtitle_margin subtitle margin |
|
||||
# #' @param strip_text_size strip text size |
|
||||
# #' @param strip_placement strip placement |
|
||||
# #' @param caption_size caption size |
|
||||
# #' @param caption_margin caption margin |
|
||||
# #' @param axis_text_size axis text size |
|
||||
# #' @param axis_title_size axis title size |
|
||||
# #' @param axis_title_just axis title just |
|
||||
# #' @param text_geom_size text geom size |
|
||||
# #' @param panel_spacing panel spacing |
|
||||
# #' @param plot_margin plot margin |
|
||||
# #' @param grid_col grid col |
|
||||
# #' @param grid grid |
|
||||
# #' @param axis_col axis col |
|
||||
# #' @param axis axis |
|
||||
# #' @param ticks ticks |
|
||||
# #' @return ggplot2 theme |
|
||||
# #' @export |
|
||||
# #' @examples |
|
||||
# #' ggplot() + |
|
||||
# #' geom_point( |
|
||||
# #' data = mtcars, |
|
||||
# #' aes(mpg, wt) |
|
||||
# #' ) + |
|
||||
# #' geom_label( |
|
||||
# #' aes( |
|
||||
# #' x = 30, y = 4.5, |
|
||||
# #' label = "A fairly useless\nannotation that\nuses the custom\nInter variant\nby default." |
|
||||
# #' ), |
|
||||
# #' label.size = 0 |
|
||||
# #' ) + |
|
||||
# #' labs( |
|
||||
# #' x = "Fuel efficiency (mpg)", y = "Weight (tons)", |
|
||||
# #' title = "Seminal ggplot2 scatterplot example", |
|
||||
# #' subtitle = "A plot that is only useful for demonstration purposes", |
|
||||
# #' caption = "Brought to you by the letter 'g'" |
|
||||
# #' ) + |
|
||||
# #' theme_inter(grid = "XY") |
|
||||
|
|
||||
# theme_inter <- function( |
|
||||
# base_size = 10, |
|
||||
# line_height = 0.875, |
|
||||
# plot_title_size = 18, |
|
||||
# plot_title_position = "panel", |
|
||||
# plot_title_margin = 10, |
|
||||
# subtitle_size = 12, |
|
||||
# subtitle_margin = 12, |
|
||||
# strip_text_size = 12, |
|
||||
# strip_placement = "outer", |
|
||||
# caption_size = 9, |
|
||||
# caption_margin = 10, |
|
||||
# axis_text_size = base_size, |
|
||||
# axis_title_size = 9, |
|
||||
# axis_title_just = "rt", |
|
||||
# panel_spacing = grid::unit(2, "lines"), |
|
||||
# plot_margin = margin(30, 30, 30, 30), |
|
||||
# mode = c("light", "dark", "rstudio"), |
|
||||
# background_colour = theme_background_color(mode, light = "white", dark = "#121212"), |
|
||||
# foreground_colour = theme_foreground_color(mode, light = "#262626", dark = "#e1e1e1"), |
|
||||
# grid_col = theme_foreground_color(mode, light = "#cccccc", dark = "#606367"), |
|
||||
# axis_col = theme_foreground_color(mode, light = "#2b2b2b", dark = "#606367"), |
|
||||
# grid = TRUE, |
|
||||
# axis = FALSE, |
|
||||
# ticks = FALSE) { |
|
||||
# |
|
||||
# base_family <- inter_pkg$normal |
|
||||
# plot_title_family <- inter_pkg$ultrabold |
|
||||
# subtitle_family <- inter_pkg$medium |
|
||||
# strip_text_family <- inter_pkg$semibold |
|
||||
# axis_text_family <- inter_pkg$normal |
|
||||
# caption_family <- inter_pkg$normal |
|
||||
# axis_title_family <- inter_pkg$medium |
|
||||
# |
|
||||
# c( |
|
||||
# "GeomRect", "GeomLabel", "GeomTile", "GeomViolin" |
|
||||
# ) -> has_reverse_cols |
|
||||
# |
|
||||
# geoms <- ls(pattern = '^Geom', env = as.environment('package:ggplot2')) |
|
||||
# |
|
||||
# for (geom in geoms) { |
|
||||
# |
|
||||
# update_geom_defaults( |
|
||||
# geom = get(geom), |
|
||||
# new = list( |
|
||||
# arrow.fill = background_colour, |
|
||||
# outlier.colour = foreground_colour, |
|
||||
# outlier.fill = background_colour, |
|
||||
# colour = foreground_colour, |
|
||||
# fill = if (geom %in% c(has_reverse_cols)) background_colour else NA, |
|
||||
# family = base_family, |
|
||||
# lineheight = line_height |
|
||||
# ) |
|
||||
# ) |
|
||||
# |
|
||||
# } |
|
||||
# |
|
||||
# theme_minimal( |
|
||||
# base_family = base_family, |
|
||||
# base_size = base_size, |
|
||||
# ) + |
|
||||
# theme( |
|
||||
# rect = element_rect(colour = foreground_colour, fill = background_colour), |
|
||||
# line = element_line(colour = foreground_colour), |
|
||||
# title = element_text(colour = foreground_colour), |
|
||||
# legend.background = element_blank(), |
|
||||
# legend.key = element_blank(), |
|
||||
# legend.text = element_text(colour = foreground_colour, family = inter_pkg$medium), |
|
||||
# legend.title = element_text(colour = foreground_colour, family = inter_pkg$semibold) |
|
||||
# ) -> ret |
|
||||
# |
|
||||
# |
|
||||
# if (inherits(grid, "character") | grid == TRUE) { |
|
||||
# |
|
||||
# ret + |
|
||||
# theme( |
|
||||
# panel.grid = element_line(colour = grid_col, size = 0.2), |
|
||||
# panel.grid.major = element_line(colour = grid_col, size = 0.2), |
|
||||
# panel.grid.minor = element_line(colour = grid_col, size = 0.15) |
|
||||
# ) -> ret |
|
||||
# |
|
||||
# if (inherits(grid, "character")) { |
|
||||
# if (regexpr("X", grid)[1] < 0) ret <- ret + theme(panel.grid.major.x = element_blank()) |
|
||||
# if (regexpr("Y", grid)[1] < 0) ret <- ret + theme(panel.grid.major.y = element_blank()) |
|
||||
# if (regexpr("x", grid)[1] < 0) ret <- ret + theme(panel.grid.minor.x = element_blank()) |
|
||||
# if (regexpr("y", grid)[1] < 0) ret <- ret + theme(panel.grid.minor.y = element_blank()) |
|
||||
# } |
|
||||
# |
|
||||
# } else { |
|
||||
# ret <- ret + theme(panel.grid = element_blank()) |
|
||||
# } |
|
||||
# |
|
||||
# if (inherits(axis, "character") | axis == TRUE) { |
|
||||
# ret <- ret + theme(axis.line = element_line(colour = axis_col, size = 0.15)) |
|
||||
# if (inherits(axis, "character")) { |
|
||||
# axis <- tolower(axis) |
|
||||
# if (regexpr("x", axis)[1] < 0) { |
|
||||
# ret <- ret + theme(axis.line.x = element_blank()) |
|
||||
# } else { |
|
||||
# ret <- ret + theme(axis.line.x = element_line(colour = axis_col, size = 0.15)) |
|
||||
# } |
|
||||
# if (regexpr("y", axis)[1] < 0) { |
|
||||
# ret <- ret + theme(axis.line.y = element_blank()) |
|
||||
# } else { |
|
||||
# ret <- ret + theme(axis.line.y = element_line(colour = axis_col, size = 0.15)) |
|
||||
# } |
|
||||
# } else { |
|
||||
# ret + theme( |
|
||||
# axis.line.x = element_line(colour = axis_col, size = 0.15), |
|
||||
# axis.line.y = element_line(colour = axis_col, size = 0.15) |
|
||||
# ) -> ret |
|
||||
# } |
|
||||
# } else { |
|
||||
# ret <- ret + theme(axis.line = element_blank()) |
|
||||
# } |
|
||||
# |
|
||||
# if (!ticks) { |
|
||||
# |
|
||||
# ret + theme( |
|
||||
# axis.ticks = element_blank(), |
|
||||
# axis.ticks.x = element_blank(), |
|
||||
# axis.ticks.y = element_blank() |
|
||||
# ) -> ret |
|
||||
# |
|
||||
# } else { |
|
||||
# |
|
||||
# ret + theme( |
|
||||
# axis.ticks = element_line(size = 0.15), |
|
||||
# axis.ticks.x = element_line(size = 0.15), |
|
||||
# axis.ticks.y = element_line(size = 0.15), |
|
||||
# axis.ticks.length = grid::unit(5, "pt") |
|
||||
# ) -> ret |
|
||||
# |
|
||||
# } |
|
||||
# |
|
||||
# xj <- switch(tolower(substr(axis_title_just, 1, 1)), b = 0, l = 0, m = 0.5, c = 0.5, r = 1, t = 1) |
|
||||
# yj <- switch(tolower(substr(axis_title_just, 2, 2)), b = 0, l = 0, m = 0.5, c = 0.5, r = 1, t = 1) |
|
||||
# |
|
||||
# ret + |
|
||||
# theme( |
|
||||
# axis.text.x = element_text(size = axis_text_size, margin = margin(t = 0), lineheight = line_height), |
|
||||
# axis.text.x.top = element_text(size = axis_text_size, margin = margin(t = 0), lineheight = line_height), |
|
||||
# axis.text.x.bottom = element_text(size = axis_text_size, margin = margin(t = 0), lineheight = line_height), |
|
||||
# |
|
||||
# axis.text.y = element_text(size = axis_text_size, margin = margin(r = 0), lineheight = line_height), |
|
||||
# axis.text.y.left = element_text(size = axis_text_size, margin = margin(r = 0), lineheight = line_height), |
|
||||
# axis.text.y.right = element_text(size = axis_text_size, margin = margin(r = 0), lineheight = line_height), |
|
||||
# |
|
||||
# axis.title = element_text( |
|
||||
# size = axis_title_size, |
|
||||
# family = axis_title_family, lineheight = line_height |
|
||||
# ), |
|
||||
# |
|
||||
# axis.title.x = element_text( |
|
||||
# hjust = xj, size = axis_title_size, |
|
||||
# family = axis_title_family, lineheight = line_height |
|
||||
# ), |
|
||||
# axis.title.x.top = element_text( |
|
||||
# hjust = xj, size = axis_title_size, |
|
||||
# family = axis_title_family, lineheight = line_height |
|
||||
# ), |
|
||||
# axis.title.x.bottom = element_text( |
|
||||
# hjust = xj, size = axis_title_size, |
|
||||
# family = axis_title_family, lineheight = line_height |
|
||||
# ), |
|
||||
# |
|
||||
# axis.title.y = element_text( |
|
||||
# hjust = yj, size = axis_title_size, |
|
||||
# family = axis_title_family, lineheight = line_height |
|
||||
# ), |
|
||||
# axis.title.y.left = element_text( |
|
||||
# hjust = yj, size = axis_title_size, |
|
||||
# family = axis_title_family, lineheight = line_height |
|
||||
# ), |
|
||||
# axis.title.y.right = element_text( |
|
||||
# hjust = yj, size = axis_title_size, angle = 90, |
|
||||
# family = axis_title_family, lineheight = line_height |
|
||||
# ), |
|
||||
# |
|
||||
# strip.placement = strip_placement, |
|
||||
# strip.text = element_text( |
|
||||
# hjust = 0, size = strip_text_size, color = foreground_colour, |
|
||||
# family = strip_text_family, lineheight = line_height |
|
||||
# ), |
|
||||
# strip.text.x = element_text( |
|
||||
# hjust = 0, size = strip_text_size, color = foreground_colour, |
|
||||
# family = strip_text_family, lineheight = line_height |
|
||||
# ), |
|
||||
# strip.background = element_rect( |
|
||||
# fill = background_colour, color = NA |
|
||||
# ), |
|
||||
# strip.background.x = element_rect( |
|
||||
# fill = background_colour, color = NA |
|
||||
# ), |
|
||||
# strip.background.y = element_rect( |
|
||||
# fill = background_colour, color = NA |
|
||||
# ), |
|
||||
# strip.text.y = element_text( |
|
||||
# hjust = 0, size = strip_text_size, color = foreground_colour, |
|
||||
# family = strip_text_family, lineheight = line_height |
|
||||
# ), |
|
||||
# panel.spacing = panel_spacing, |
|
||||
# panel.background = element_rect(color = NA, fill = background_colour), |
|
||||
# plot.background = element_rect(color = NA, fill = background_colour), |
|
||||
# plot.title.position = plot_title_position, |
|
||||
# plot.margin = plot_margin, |
|
||||
# plot.title = element_text( |
|
||||
# hjust = 0, size = plot_title_size, margin = margin(b = plot_title_margin), |
|
||||
# family = plot_title_family, lineheight = line_height |
|
||||
# ), |
|
||||
# plot.subtitle = element_text( |
|
||||
# hjust = 0, size = subtitle_size, margin = margin(b = subtitle_margin), |
|
||||
# family = subtitle_family, lineheight = line_height |
|
||||
# ), |
|
||||
# plot.caption = element_text( |
|
||||
# hjust = 1, size = caption_size, margin = margin(t = caption_margin), |
|
||||
# family = caption_family, lineheight = line_height |
|
||||
# ), |
|
||||
# ) -> ret |
|
||||
# |
|
||||
# ret |
|
||||
# |
|
||||
# } |
|
@ -0,0 +1,339 @@ |
|||||
|
# Stolen from ggplot2 |
||||
|
is.waive <- function (x) { inherits(x, "waiver") } |
||||
|
is.sec_axis <- function (x) { inherits(x, "AxisSecondary") } |
||||
|
is.formula <- function (x) { inherits(x, "formula") } |
||||
|
|
||||
|
#' X & Y scales with opinionated pre-sets for percent & comma label formats |
||||
|
#' |
||||
|
#' The `_comma` ones set comma format for axis text and `expand=c(0,0)` (you need to set limits). |
||||
|
#' |
||||
|
#' The `_percent` ones set precent format for axis text and `expand=c(0,0)` (you need to set limits). |
||||
|
#' |
||||
|
#' @md |
||||
|
#' @param name The name of the scale. Used as axis or legend title. If |
||||
|
#' `waiver()`, the default, the name of the scale is taken from the first |
||||
|
#' mapping used for that aesthetic. If `NULL`, the legend title will be |
||||
|
#' omitted. |
||||
|
#' @param breaks One of: |
||||
|
#' - `NULL` for no breaks |
||||
|
#' - `waiver()` for the default breaks computed by the |
||||
|
#' transformation object |
||||
|
#' - A numeric vector of positions |
||||
|
#' - A function that takes the limits as input and returns breaks |
||||
|
#' as output |
||||
|
#' @param minor_breaks One of: |
||||
|
#' - `NULL` for no minor breaks |
||||
|
#' - `waiver()` for the default breaks (one minor break between |
||||
|
#' each major break) |
||||
|
#' - A numeric vector of positions |
||||
|
#' - A function that given the limits returns a vector of minor breaks. |
||||
|
#' @param guide guide A function used to create a guide or its name. See [guides()] for more information. |
||||
|
#' @param n.breaks An integer guiding the number of major breaks. The algorithm may choose a |
||||
|
#' slightly different number to ensure nice break labels. Will only have an effect if |
||||
|
#' `breaks = waiver()`. Use NULL to use the default number of breaks given by the transformation. |
||||
|
#' @param labels Specifying overrides the default format (i.e. you really don't |
||||
|
#' want to do that). `NULL` means no labels. |
||||
|
#' @param limits A numeric vector of length two providing limits of the scale. |
||||
|
#' Use `NA` to refer to the existing minimum or maximum. |
||||
|
#' @param oob Function that handles limits outside of the scale limits |
||||
|
#' (out of bounds). The default replaces out of bounds values with NA. |
||||
|
#' @param na.value If `na.translate = TRUE`, what value aesthetic |
||||
|
#' value should missing be displayed as? Does not apply to position scales |
||||
|
#' where `NA` is always placed at the far right. |
||||
|
#' @param expand same as in ggplot2 |
||||
|
#' @param trans Either the name of a transformation object, or the |
||||
|
#' object itself. Built-in transformations include "asn", "atanh", |
||||
|
#' "boxcox", "exp", "identity", "log", "log10", "log1p", "log2", |
||||
|
#' "logit", "probability", "probit", "reciprocal", "reverse" and "sqrt". |
||||
|
#' @param position The position of the axis. "left" or "right" for vertical |
||||
|
#' scales, "top" or "bottom" for horizontal scales |
||||
|
#' @param sec.axis specify a secondary axis |
||||
|
#' @export |
||||
|
scale_x_percent <- function(name = waiver(), |
||||
|
breaks = waiver(), |
||||
|
minor_breaks = waiver(), |
||||
|
guide = waiver(), |
||||
|
n.breaks = NULL, |
||||
|
labels, |
||||
|
limits = NULL, |
||||
|
expand = c(0.01,0), |
||||
|
oob = censor, |
||||
|
na.value = NA_real_, |
||||
|
trans = "identity", |
||||
|
position = "bottom", |
||||
|
sec.axis = waiver(), |
||||
|
accuracy = 1, |
||||
|
scale = 100, |
||||
|
prefix = "", |
||||
|
suffix = "%", |
||||
|
big.mark = " ", |
||||
|
decimal.mark = ".", |
||||
|
trim = TRUE, ...) { |
||||
|
|
||||
|
if (missing(labels)) { |
||||
|
scales::percent_format( |
||||
|
accuracy = accuracy, |
||||
|
scale = scale, |
||||
|
prefix = prefix, |
||||
|
suffix = suffix, |
||||
|
big.mark = big.mark, |
||||
|
decimal.mark = decimal.mark, |
||||
|
trim = trim, |
||||
|
... |
||||
|
) -> labels |
||||
|
} |
||||
|
|
||||
|
ggplot2::continuous_scale( |
||||
|
aesthetics = c( |
||||
|
"x", "xmin", "xmax", "xend", "xintercept", "xmin_final", |
||||
|
"xmax_final", "xlower", "xmiddle", "xupper", "x0" |
||||
|
), |
||||
|
scale_name = "position_c", |
||||
|
palette = identity, |
||||
|
name = name, |
||||
|
breaks = breaks, |
||||
|
n.breaks = n.breaks, |
||||
|
minor_breaks = minor_breaks, |
||||
|
labels = labels, |
||||
|
limits = limits, |
||||
|
expand = expand, |
||||
|
oob = oob, |
||||
|
na.value = na.value, |
||||
|
trans = trans, |
||||
|
guide = guide, |
||||
|
position = position, |
||||
|
super = ScaleContinuousPosition |
||||
|
) -> sc |
||||
|
|
||||
|
if (!is.waive(sec.axis)) { |
||||
|
|
||||
|
if (is.formula(sec.axis)) sec.axis <- sec_axis(sec.axis) |
||||
|
if (!is.sec_axis(sec.axis)) stop("Secondary axes must be specified using 'sec_axis()'") |
||||
|
|
||||
|
sc$secondary.axis <- sec.axis |
||||
|
|
||||
|
} |
||||
|
|
||||
|
sc |
||||
|
|
||||
|
} |
||||
|
|
||||
|
#' @rdname scale_x_percent |
||||
|
#' @export |
||||
|
scale_y_percent <- function(name = waiver(), |
||||
|
breaks = waiver(), |
||||
|
minor_breaks = waiver(), |
||||
|
guide = waiver(), |
||||
|
n.breaks = NULL, |
||||
|
labels, |
||||
|
limits = NULL, |
||||
|
expand = c(0.01,0), |
||||
|
oob = censor, |
||||
|
na.value = NA_real_, |
||||
|
trans = "identity", |
||||
|
position = "left", |
||||
|
sec.axis = waiver(), |
||||
|
accuracy = 1, |
||||
|
scale = 100, |
||||
|
prefix = "", |
||||
|
suffix = "%", |
||||
|
big.mark = " ", |
||||
|
decimal.mark = ".", |
||||
|
trim = TRUE, ...) { |
||||
|
|
||||
|
if (missing(labels)) { |
||||
|
scales::percent_format( |
||||
|
accuracy = accuracy, |
||||
|
scale = scale, |
||||
|
prefix = prefix, |
||||
|
suffix = suffix, |
||||
|
big.mark = big.mark, |
||||
|
decimal.mark = decimal.mark, |
||||
|
trim = trim, |
||||
|
... |
||||
|
) -> labels |
||||
|
} |
||||
|
|
||||
|
ggplot2::continuous_scale( |
||||
|
aesthetics = c( |
||||
|
"y", "ymin", "ymax", "yend", "yintercept", |
||||
|
"ymin_final", "ymax_final", "lower", "middle", "upper" |
||||
|
), |
||||
|
scale_name = "position_c", |
||||
|
palette = identity, |
||||
|
name = name, |
||||
|
breaks = breaks, |
||||
|
n.breaks = n.breaks, |
||||
|
minor_breaks = minor_breaks, |
||||
|
labels = labels, |
||||
|
limits = limits, |
||||
|
expand = expand, |
||||
|
oob = oob, |
||||
|
na.value = na.value, |
||||
|
trans = trans, |
||||
|
guide = guide, |
||||
|
position = position, |
||||
|
super = ScaleContinuousPosition |
||||
|
) -> sc |
||||
|
|
||||
|
if (!is.waive(sec.axis)) { |
||||
|
|
||||
|
if (is.formula(sec.axis)) sec.axis <- ggplot2::sec_axis(sec.axis) |
||||
|
if (!is.sec_axis(sec.axis)) stop("Secondary axes must be specified using 'sec_axis()'") |
||||
|
|
||||
|
sc$secondary.axis <- sec.axis |
||||
|
|
||||
|
} |
||||
|
|
||||
|
sc |
||||
|
|
||||
|
} |
||||
|
|
||||
|
#' @rdname scale_x_percent |
||||
|
#' @param accuracy,scale,prefix,suffix,big.mark,decimal.mark,trim See |
||||
|
#' [scales::comma_format()] or [scales::percent_format()] |
||||
|
#' @param ... passed on to [scales::comma_format()] or [scales::percent_format()] |
||||
|
#' @export |
||||
|
scale_x_comma <- function(name = waiver(), |
||||
|
breaks = waiver(), |
||||
|
minor_breaks = waiver(), |
||||
|
guide = waiver(), |
||||
|
n.breaks = NULL, |
||||
|
labels, |
||||
|
limits = NULL, |
||||
|
expand = c(0.01,0), |
||||
|
oob = censor, |
||||
|
na.value = NA_real_, |
||||
|
trans = "identity", |
||||
|
position = "bottom", |
||||
|
sec.axis = waiver(), |
||||
|
accuracy = 1, |
||||
|
scale = 1, |
||||
|
prefix = "", |
||||
|
suffix = "", |
||||
|
big.mark = ",", |
||||
|
decimal.mark = ".", |
||||
|
trim = TRUE, |
||||
|
...) { |
||||
|
|
||||
|
if (missing(labels)) { |
||||
|
scales::comma_format( |
||||
|
accuracy = accuracy, |
||||
|
scale = scale, |
||||
|
prefix = prefix, |
||||
|
suffix = suffix, |
||||
|
big.mark = big.mark, |
||||
|
decimal.mark = decimal.mark, |
||||
|
trim = trim, |
||||
|
... |
||||
|
) -> labels |
||||
|
} |
||||
|
|
||||
|
ggplot2::continuous_scale( |
||||
|
aesthetics = c( |
||||
|
"x", "xmin", "xmax", "xend", "xintercept", |
||||
|
"xmin_final", "xmax_final", |
||||
|
"xlower", "xmiddle", "xupper" |
||||
|
), |
||||
|
scale_name = "position_c", |
||||
|
palette = identity, |
||||
|
name = name, |
||||
|
breaks = breaks, |
||||
|
n.breaks = n.breaks, |
||||
|
minor_breaks = minor_breaks, |
||||
|
labels = labels, |
||||
|
limits = limits, |
||||
|
expand = expand, |
||||
|
oob = oob, |
||||
|
na.value = na.value, |
||||
|
trans = trans, |
||||
|
guide = guide, |
||||
|
position = position, |
||||
|
super = ScaleContinuousPosition |
||||
|
) -> sc |
||||
|
|
||||
|
if (!is.waive(sec.axis)) { |
||||
|
|
||||
|
if (is.formula(sec.axis)) sec.axis <- ggplot2::sec_axis(sec.axis) |
||||
|
if (!is.sec_axis(sec.axis)) stop("Secondary axes must be specified using 'sec_axis()'") |
||||
|
|
||||
|
sc$secondary.axis <- sec.axis |
||||
|
|
||||
|
} |
||||
|
|
||||
|
sc |
||||
|
|
||||
|
} |
||||
|
|
||||
|
#' @rdname scale_x_percent |
||||
|
#' @export |
||||
|
scale_y_comma <- function(name = waiver(), |
||||
|
breaks = waiver(), |
||||
|
minor_breaks = waiver(), |
||||
|
guide = waiver(), |
||||
|
n.breaks = NULL, |
||||
|
labels, |
||||
|
limits = NULL, |
||||
|
expand = c(0.01,0), |
||||
|
oob = censor, |
||||
|
na.value = NA_real_, |
||||
|
trans = "identity", |
||||
|
position = "left", |
||||
|
sec.axis = waiver(), |
||||
|
accuracy = 1, |
||||
|
scale = 1, |
||||
|
prefix = "", |
||||
|
suffix = "", |
||||
|
big.mark = ",", |
||||
|
decimal.mark = ".", |
||||
|
trim = TRUE, |
||||
|
...) { |
||||
|
|
||||
|
if (missing(labels)) { |
||||
|
scales::comma_format( |
||||
|
accuracy = accuracy, |
||||
|
scale = scale, |
||||
|
prefix = prefix, |
||||
|
suffix = suffix, |
||||
|
big.mark = big.mark, |
||||
|
decimal.mark = decimal.mark, |
||||
|
trim = trim, |
||||
|
... |
||||
|
) -> labels |
||||
|
} |
||||
|
|
||||
|
ggplot2::continuous_scale( |
||||
|
aesthetics = c( |
||||
|
"y", "ymin", "ymax", "yend", "yintercept", |
||||
|
"ymin_final", "ymax_final", |
||||
|
"lower", "middle", "upper" |
||||
|
), |
||||
|
scale_name = "position_c", |
||||
|
palette = identity, |
||||
|
name = name, |
||||
|
breaks = breaks, |
||||
|
n.breaks = n.breaks, |
||||
|
minor_breaks = minor_breaks, |
||||
|
labels = labels, |
||||
|
limits = limits, |
||||
|
expand = expand, |
||||
|
oob = oob, |
||||
|
na.value = na.value, |
||||
|
trans = trans, |
||||
|
guide = guide, |
||||
|
position = position, |
||||
|
super = ScaleContinuousPosition |
||||
|
) -> sc |
||||
|
|
||||
|
if (!is.waive(sec.axis)) { |
||||
|
|
||||
|
if (is.formula(sec.axis)) sec.axis <- ggplot2::sec_axis(sec.axis) |
||||
|
if (!is.sec_axis(sec.axis)) stop("Secondary axes must be specified using 'sec_axis()'") |
||||
|
|
||||
|
sc$secondary.axis <- sec.axis |
||||
|
|
||||
|
} |
||||
|
|
||||
|
sc |
||||
|
|
||||
|
} |
@ -0,0 +1,278 @@ |
|||||
|
#' ggplot2 Theme Based On The Goldman Sans Font Family |
||||
|
#' |
||||
|
#' Uses the built-in [gs_pkg] custom font. |
||||
|
#' |
||||
|
#' - `background_colour` dark mode is "`#121212`" else "`white`" |
||||
|
#' - `foreground_colour` dark mode is "`#e1e1e1`" else "`#262626`" |
||||
|
#' - `grid_col` dark mode is "`#606367`" else "`#cccccc`" |
||||
|
#' - `axis_col` dark mode is "`#606367`" else "`#2b2b2b`" |
||||
|
#' |
||||
|
#' @note this function updates `Geom` defaults; use [reset_ggplot2_defaults()] to |
||||
|
#' restore ggplot2 geom default aeshetics |
||||
|
#' @param base_size base font size |
||||
|
#' @param line_height default line height |
||||
|
#' @param plot_title_size plot title size |
||||
|
#' @param plot_title_position plot title position |
||||
|
#' @param plot_title_margin plot title margin |
||||
|
#' @param subtitle_size subtitle size |
||||
|
#' @param subtitle_margin subtitle margin |
||||
|
#' @param strip_text_size strip text size |
||||
|
#' @param strip_placement strip placement |
||||
|
#' @param caption_size caption size |
||||
|
#' @param caption_margin caption margin |
||||
|
#' @param axis_text_size axis text size |
||||
|
#' @param axis_title_size axis title size |
||||
|
#' @param axis_title_just axis title just |
||||
|
#' @param text_geom_size text geom size |
||||
|
#' @param panel_spacing panel spacing |
||||
|
#' @param plot_margin plot margin |
||||
|
#' @param grid_col grid col |
||||
|
#' @param grid grid |
||||
|
#' @param axis_col axis col |
||||
|
#' @param axis axis |
||||
|
#' @param ticks ticks |
||||
|
#' @return ggplot2 theme |
||||
|
#' @export |
||||
|
#' @examples |
||||
|
#' ggplot() + |
||||
|
#' geom_point( |
||||
|
#' data = mtcars, |
||||
|
#' aes(mpg, wt) |
||||
|
#' ) + |
||||
|
#' geom_label( |
||||
|
#' aes( |
||||
|
#' x = 30, y = 4.5, |
||||
|
#' label = "A fairly useless\nannotation that\nuses the custom\nInter variant\nby default." |
||||
|
#' ), |
||||
|
#' label.size = 0 |
||||
|
#' ) + |
||||
|
#' labs( |
||||
|
#' x = "Fuel efficiency (mpg)", y = "Weight (tons)", |
||||
|
#' title = "Seminal ggplot2 scatterplot example", |
||||
|
#' subtitle = "A plot that is only useful for demonstration purposes", |
||||
|
#' caption = "Brought to you by the letter 'g'" |
||||
|
#' ) + |
||||
|
#' theme_gs(grid = "XY") |
||||
|
theme_gs <- function( |
||||
|
base_size = 11.5, |
||||
|
line_height = 0.875, |
||||
|
plot_title_size = 18, |
||||
|
plot_title_position = "panel", |
||||
|
plot_title_margin = 10, |
||||
|
subtitle_size = 12, |
||||
|
subtitle_margin = 12, |
||||
|
strip_text_size = 12, |
||||
|
strip_placement = "outer", |
||||
|
caption_size = 10, |
||||
|
caption_margin = 10, |
||||
|
axis_text_size = base_size, |
||||
|
axis_title_size = 10, |
||||
|
axis_title_just = "rt", |
||||
|
panel_spacing = grid::unit(2, "lines"), |
||||
|
plot_margin = margin(30, 30, 30, 30), |
||||
|
mode = c("light", "dark", "rstudio"), |
||||
|
background_colour = theme_background_color(mode, light = "white", dark = "#121212"), |
||||
|
foreground_colour = theme_foreground_color(mode, light = "#262626", dark = "#e1e1e1"), |
||||
|
grid_col = theme_foreground_color(mode, light = "#cccccc", dark = "#606367"), |
||||
|
axis_col = theme_foreground_color(mode, light = "#2b2b2b", dark = "#606367"), |
||||
|
grid = TRUE, |
||||
|
axis = FALSE, |
||||
|
ticks = FALSE) { |
||||
|
|
||||
|
base_family <- gsc_pkg$normal |
||||
|
plot_title_family <- gs_pkg$bold |
||||
|
subtitle_family <- gs_pkg$normal |
||||
|
strip_text_family <- gsc_pkg$bold |
||||
|
axis_text_family <- gsc_pkg$normal |
||||
|
caption_family <- gsc_pkg$normal |
||||
|
axis_title_family <- gs_pkg$medium |
||||
|
|
||||
|
c( |
||||
|
"GeomRect", "GeomLabel", "GeomTile", "GeomViolin" |
||||
|
) -> has_reverse_cols |
||||
|
|
||||
|
geoms <- ls(pattern = '^Geom', env = as.environment('package:ggplot2')) |
||||
|
|
||||
|
for (geom in geoms) { |
||||
|
|
||||
|
update_geom_defaults( |
||||
|
geom = get(geom), |
||||
|
new = list( |
||||
|
arrow.fill = background_colour, |
||||
|
outlier.colour = foreground_colour, |
||||
|
outlier.fill = background_colour, |
||||
|
colour = foreground_colour, |
||||
|
fill = if (geom %in% c(has_reverse_cols)) background_colour else NA, |
||||
|
family = base_family, |
||||
|
lineheight = line_height |
||||
|
) |
||||
|
) |
||||
|
|
||||
|
} |
||||
|
|
||||
|
theme_minimal( |
||||
|
base_family = base_family, |
||||
|
base_size = base_size, |
||||
|
) + |
||||
|
theme( |
||||
|
rect = element_rect(colour = foreground_colour, fill = background_colour), |
||||
|
line = element_line(colour = foreground_colour), |
||||
|
title = element_text(colour = foreground_colour), |
||||
|
legend.background = element_blank(), |
||||
|
legend.key = element_blank(), |
||||
|
legend.text = element_text(colour = foreground_colour, family = inter_pkg$medium), |
||||
|
legend.title = element_text(colour = foreground_colour, family = inter_pkg$semibold) |
||||
|
) -> ret |
||||
|
|
||||
|
|
||||
|
if (inherits(grid, "character") | grid == TRUE) { |
||||
|
|
||||
|
ret + |
||||
|
theme( |
||||
|
panel.grid = element_line(colour = grid_col, size = 0.2), |
||||
|
panel.grid.major = element_line(colour = grid_col, size = 0.2), |
||||
|
panel.grid.minor = element_line(colour = grid_col, size = 0.15) |
||||
|
) -> ret |
||||
|
|
||||
|
if (inherits(grid, "character")) { |
||||
|
if (regexpr("X", grid)[1] < 0) ret <- ret + theme(panel.grid.major.x = element_blank()) |
||||
|
if (regexpr("Y", grid)[1] < 0) ret <- ret + theme(panel.grid.major.y = element_blank()) |
||||
|
if (regexpr("x", grid)[1] < 0) ret <- ret + theme(panel.grid.minor.x = element_blank()) |
||||
|
if (regexpr("y", grid)[1] < 0) ret <- ret + theme(panel.grid.minor.y = element_blank()) |
||||
|
} |
||||
|
|
||||
|
} else { |
||||
|
ret <- ret + theme(panel.grid = element_blank()) |
||||
|
} |
||||
|
|
||||
|
if (inherits(axis, "character") | axis == TRUE) { |
||||
|
ret <- ret + theme(axis.line = element_line(colour = axis_col, size = 0.15)) |
||||
|
if (inherits(axis, "character")) { |
||||
|
axis <- tolower(axis) |
||||
|
if (regexpr("x", axis)[1] < 0) { |
||||
|
ret <- ret + theme(axis.line.x = element_blank()) |
||||
|
} else { |
||||
|
ret <- ret + theme(axis.line.x = element_line(colour = axis_col, size = 0.15)) |
||||
|
} |
||||
|
if (regexpr("y", axis)[1] < 0) { |
||||
|
ret <- ret + theme(axis.line.y = element_blank()) |
||||
|
} else { |
||||
|
ret <- ret + theme(axis.line.y = element_line(colour = axis_col, size = 0.15)) |
||||
|
} |
||||
|
} else { |
||||
|
ret + theme( |
||||
|
axis.line.x = element_line(colour = axis_col, size = 0.15), |
||||
|
axis.line.y = element_line(colour = axis_col, size = 0.15) |
||||
|
) -> ret |
||||
|
} |
||||
|
} else { |
||||
|
ret <- ret + theme(axis.line = element_blank()) |
||||
|
} |
||||
|
|
||||
|
if (!ticks) { |
||||
|
|
||||
|
ret + theme( |
||||
|
axis.ticks = element_blank(), |
||||
|
axis.ticks.x = element_blank(), |
||||
|
axis.ticks.y = element_blank() |
||||
|
) -> ret |
||||
|
|
||||
|
} else { |
||||
|
|
||||
|
ret + theme( |
||||
|
axis.ticks = element_line(size = 0.15), |
||||
|
axis.ticks.x = element_line(size = 0.15), |
||||
|
axis.ticks.y = element_line(size = 0.15), |
||||
|
axis.ticks.length = grid::unit(5, "pt") |
||||
|
) -> ret |
||||
|
|
||||
|
} |
||||
|
|
||||
|
xj <- switch(tolower(substr(axis_title_just, 1, 1)), b = 0, l = 0, m = 0.5, c = 0.5, r = 1, t = 1) |
||||
|
yj <- switch(tolower(substr(axis_title_just, 2, 2)), b = 0, l = 0, m = 0.5, c = 0.5, r = 1, t = 1) |
||||
|
|
||||
|
ret + |
||||
|
theme( |
||||
|
axis.text.x = element_text(size = axis_text_size, margin = margin(t = 0), lineheight = line_height), |
||||
|
axis.text.x.top = element_text(size = axis_text_size, margin = margin(t = 0), lineheight = line_height), |
||||
|
axis.text.x.bottom = element_text(size = axis_text_size, margin = margin(t = 0), lineheight = line_height), |
||||
|
|
||||
|
axis.text.y = element_text(size = axis_text_size, margin = margin(r = 0), lineheight = line_height), |
||||
|
axis.text.y.left = element_text(size = axis_text_size, margin = margin(r = 0), lineheight = line_height), |
||||
|
axis.text.y.right = element_text(size = axis_text_size, margin = margin(r = 0), lineheight = line_height), |
||||
|
|
||||
|
axis.title = element_text( |
||||
|
size = axis_title_size, |
||||
|
family = axis_title_family, lineheight = line_height |
||||
|
), |
||||
|
|
||||
|
axis.title.x = element_text( |
||||
|
hjust = xj, size = axis_title_size, |
||||
|
family = axis_title_family, lineheight = line_height |
||||
|
), |
||||
|
axis.title.x.top = element_text( |
||||
|
hjust = xj, size = axis_title_size, |
||||
|
family = axis_title_family, lineheight = line_height |
||||
|
), |
||||
|
axis.title.x.bottom = element_text( |
||||
|
hjust = xj, size = axis_title_size, |
||||
|
family = axis_title_family, lineheight = line_height |
||||
|
), |
||||
|
|
||||
|
axis.title.y = element_text( |
||||
|
hjust = yj, size = axis_title_size, |
||||
|
family = axis_title_family, lineheight = line_height |
||||
|
), |
||||
|
axis.title.y.left = element_text( |
||||
|
hjust = yj, size = axis_title_size, |
||||
|
family = axis_title_family, lineheight = line_height |
||||
|
), |
||||
|
axis.title.y.right = element_text( |
||||
|
hjust = yj, size = axis_title_size, angle = 90, |
||||
|
family = axis_title_family, lineheight = line_height |
||||
|
), |
||||
|
|
||||
|
strip.placement = strip_placement, |
||||
|
strip.text = element_text( |
||||
|
hjust = 0, size = strip_text_size, color = foreground_colour, |
||||
|
family = strip_text_family, lineheight = line_height |
||||
|
), |
||||
|
strip.text.x = element_text( |
||||
|
hjust = 0, size = strip_text_size, color = foreground_colour, |
||||
|
family = strip_text_family, lineheight = line_height |
||||
|
), |
||||
|
strip.background = element_rect( |
||||
|
fill = background_colour, color = NA |
||||
|
), |
||||
|
strip.background.x = element_rect( |
||||
|
fill = background_colour, color = NA |
||||
|
), |
||||
|
strip.background.y = element_rect( |
||||
|
fill = background_colour, color = NA |
||||
|
), |
||||
|
strip.text.y = element_text( |
||||
|
hjust = 0, size = strip_text_size, color = foreground_colour, |
||||
|
family = strip_text_family, lineheight = line_height |
||||
|
), |
||||
|
panel.spacing = panel_spacing, |
||||
|
panel.background = element_rect(color = NA, fill = background_colour), |
||||
|
plot.background = element_rect(color = NA, fill = background_colour), |
||||
|
plot.title.position = plot_title_position, |
||||
|
plot.margin = plot_margin, |
||||
|
plot.title = element_text( |
||||
|
hjust = 0, size = plot_title_size, margin = margin(b = plot_title_margin), |
||||
|
family = plot_title_family, lineheight = line_height |
||||
|
), |
||||
|
plot.subtitle = element_text( |
||||
|
hjust = 0, size = subtitle_size, margin = margin(b = subtitle_margin), |
||||
|
family = subtitle_family, lineheight = line_height |
||||
|
), |
||||
|
plot.caption = element_text( |
||||
|
hjust = 1, size = caption_size, margin = margin(t = caption_margin), |
||||
|
family = caption_family, lineheight = line_height |
||||
|
), |
||||
|
) -> ret |
||||
|
|
||||
|
ret |
||||
|
|
||||
|
} |
@ -0,0 +1,278 @@ |
|||||
|
#' ggplot2 Theme Based On The Roboto Condensed Font Family |
||||
|
#' |
||||
|
#' Uses the built-in [rc_pkg] custom font. |
||||
|
#' |
||||
|
#' - `background_colour` dark mode is "`#121212`" else "`white`" |
||||
|
#' - `foreground_colour` dark mode is "`#e1e1e1`" else "`#262626`" |
||||
|
#' - `grid_col` dark mode is "`#606367`" else "`#cccccc`" |
||||
|
#' - `axis_col` dark mode is "`#606367`" else "`#2b2b2b`" |
||||
|
#' |
||||
|
#' @note this function updates `Geom` defaults; use [reset_ggplot2_defaults()] to |
||||
|
#' restore ggplot2 geom default aeshetics |
||||
|
#' @param base_size base font size |
||||
|
#' @param line_height default line height |
||||
|
#' @param plot_title_size plot title size |
||||
|
#' @param plot_title_position plot title position |
||||
|
#' @param plot_title_margin plot title margin |
||||
|
#' @param subtitle_size subtitle size |
||||
|
#' @param subtitle_margin subtitle margin |
||||
|
#' @param strip_text_size strip text size |
||||
|
#' @param strip_placement strip placement |
||||
|
#' @param caption_size caption size |
||||
|
#' @param caption_margin caption margin |
||||
|
#' @param axis_text_size axis text size |
||||
|
#' @param axis_title_size axis title size |
||||
|
#' @param axis_title_just axis title just |
||||
|
#' @param text_geom_size text geom size |
||||
|
#' @param panel_spacing panel spacing |
||||
|
#' @param plot_margin plot margin |
||||
|
#' @param grid_col grid col |
||||
|
#' @param grid grid |
||||
|
#' @param axis_col axis col |
||||
|
#' @param axis axis |
||||
|
#' @param ticks ticks |
||||
|
#' @return ggplot2 theme |
||||
|
#' @export |
||||
|
#' @examples |
||||
|
#' ggplot() + |
||||
|
#' geom_point( |
||||
|
#' data = mtcars, |
||||
|
#' aes(mpg, wt) |
||||
|
#' ) + |
||||
|
#' geom_label( |
||||
|
#' aes( |
||||
|
#' x = 30, y = 4.5, |
||||
|
#' label = "A fairly useless\nannotation that\nuses the custom\nInter variant\nby default." |
||||
|
#' ), |
||||
|
#' label.size = 0 |
||||
|
#' ) + |
||||
|
#' labs( |
||||
|
#' x = "Fuel efficiency (mpg)", y = "Weight (tons)", |
||||
|
#' title = "Seminal ggplot2 scatterplot example", |
||||
|
#' subtitle = "A plot that is only useful for demonstration purposes", |
||||
|
#' caption = "Brought to you by the letter 'g'" |
||||
|
#' ) + |
||||
|
#' theme_rc(grid = "XY") |
||||
|
theme_rc <- function( |
||||
|
base_size = 10, |
||||
|
line_height = 0.875, |
||||
|
plot_title_size = 18, |
||||
|
plot_title_position = "panel", |
||||
|
plot_title_margin = 10, |
||||
|
subtitle_size = 12, |
||||
|
subtitle_margin = 12, |
||||
|
strip_text_size = 12, |
||||
|
strip_placement = "outer", |
||||
|
caption_size = 9, |
||||
|
caption_margin = 10, |
||||
|
axis_text_size = base_size, |
||||
|
axis_title_size = 9, |
||||
|
axis_title_just = "rt", |
||||
|
panel_spacing = grid::unit(2, "lines"), |
||||
|
plot_margin = margin(30, 30, 30, 30), |
||||
|
mode = c("light", "dark", "rstudio"), |
||||
|
background_colour = theme_background_color(mode, light = "white", dark = "#121212"), |
||||
|
foreground_colour = theme_foreground_color(mode, light = "#262626", dark = "#e1e1e1"), |
||||
|
grid_col = theme_foreground_color(mode, light = "#cccccc", dark = "#606367"), |
||||
|
axis_col = theme_foreground_color(mode, light = "#2b2b2b", dark = "#606367"), |
||||
|
grid = TRUE, |
||||
|
axis = FALSE, |
||||
|
ticks = FALSE) { |
||||
|
|
||||
|
base_family <- rc_pkg$normal |
||||
|
plot_title_family <- rc_pkg$bold |
||||
|
subtitle_family <- rc_pkg$normal |
||||
|
strip_text_family <- rc_pkg$bold |
||||
|
axis_text_family <- rc_pkg$normal |
||||
|
caption_family <- rc_pkg$normal_light |
||||
|
axis_title_family <- rc_pkg$bold |
||||
|
|
||||
|
c( |
||||
|
"GeomRect", "GeomLabel", "GeomTile", "GeomViolin" |
||||
|
) -> has_reverse_cols |
||||
|
|
||||
|
geoms <- ls(pattern = '^Geom', env = as.environment('package:ggplot2')) |
||||
|
|
||||
|
for (geom in geoms) { |
||||
|
|
||||
|
update_geom_defaults( |
||||
|
geom = get(geom), |
||||
|
new = list( |
||||
|
arrow.fill = background_colour, |
||||
|
outlier.colour = foreground_colour, |
||||
|
outlier.fill = background_colour, |
||||
|
colour = foreground_colour, |
||||
|
fill = if (geom %in% c(has_reverse_cols)) background_colour else NA, |
||||
|
family = base_family, |
||||
|
lineheight = line_height |
||||
|
) |
||||
|
) |
||||
|
|
||||
|
} |
||||
|
|
||||
|
theme_minimal( |
||||
|
base_family = base_family, |
||||
|
base_size = base_size, |
||||
|
) + |
||||
|
theme( |
||||
|
rect = element_rect(colour = foreground_colour, fill = background_colour), |
||||
|
line = element_line(colour = foreground_colour), |
||||
|
title = element_text(colour = foreground_colour), |
||||
|
legend.background = element_blank(), |
||||
|
legend.key = element_blank(), |
||||
|
legend.text = element_text(colour = foreground_colour, family = inter_pkg$medium), |
||||
|
legend.title = element_text(colour = foreground_colour, family = inter_pkg$semibold) |
||||
|
) -> ret |
||||
|
|
||||
|
|
||||
|
if (inherits(grid, "character") | grid == TRUE) { |
||||
|
|
||||
|
ret + |
||||
|
theme( |
||||
|
panel.grid = element_line(colour = grid_col, size = 0.2), |
||||
|
panel.grid.major = element_line(colour = grid_col, size = 0.2), |
||||
|
panel.grid.minor = element_line(colour = grid_col, size = 0.15) |
||||
|
) -> ret |
||||
|
|
||||
|
if (inherits(grid, "character")) { |
||||
|
if (regexpr("X", grid)[1] < 0) ret <- ret + theme(panel.grid.major.x = element_blank()) |
||||
|
if (regexpr("Y", grid)[1] < 0) ret <- ret + theme(panel.grid.major.y = element_blank()) |
||||
|
if (regexpr("x", grid)[1] < 0) ret <- ret + theme(panel.grid.minor.x = element_blank()) |
||||
|
if (regexpr("y", grid)[1] < 0) ret <- ret + theme(panel.grid.minor.y = element_blank()) |
||||
|
} |
||||
|
|
||||
|
} else { |
||||
|
ret <- ret + theme(panel.grid = element_blank()) |
||||
|
} |
||||
|
|
||||
|
if (inherits(axis, "character") | axis == TRUE) { |
||||
|
ret <- ret + theme(axis.line = element_line(colour = axis_col, size = 0.15)) |
||||
|
if (inherits(axis, "character")) { |
||||
|
axis <- tolower(axis) |
||||
|
if (regexpr("x", axis)[1] < 0) { |
||||
|
ret <- ret + theme(axis.line.x = element_blank()) |
||||
|
} else { |
||||
|
ret <- ret + theme(axis.line.x = element_line(colour = axis_col, size = 0.15)) |
||||
|
} |
||||
|
if (regexpr("y", axis)[1] < 0) { |
||||
|
ret <- ret + theme(axis.line.y = element_blank()) |
||||
|
} else { |
||||
|
ret <- ret + theme(axis.line.y = element_line(colour = axis_col, size = 0.15)) |
||||
|
} |
||||
|
} else { |
||||
|
ret + theme( |
||||
|
axis.line.x = element_line(colour = axis_col, size = 0.15), |
||||
|
axis.line.y = element_line(colour = axis_col, size = 0.15) |
||||
|
) -> ret |
||||
|
} |
||||
|
} else { |
||||
|
ret <- ret + theme(axis.line = element_blank()) |
||||
|
} |
||||
|
|
||||
|
if (!ticks) { |
||||
|
|
||||
|
ret + theme( |
||||
|
axis.ticks = element_blank(), |
||||
|
axis.ticks.x = element_blank(), |
||||
|
axis.ticks.y = element_blank() |
||||
|
) -> ret |
||||
|
|
||||
|
} else { |
||||
|
|
||||
|
ret + theme( |
||||
|
axis.ticks = element_line(size = 0.15), |
||||
|
axis.ticks.x = element_line(size = 0.15), |
||||
|
axis.ticks.y = element_line(size = 0.15), |
||||
|
axis.ticks.length = grid::unit(5, "pt") |
||||
|
) -> ret |
||||
|
|
||||
|
} |
||||
|
|
||||
|
xj <- switch(tolower(substr(axis_title_just, 1, 1)), b = 0, l = 0, m = 0.5, c = 0.5, r = 1, t = 1) |
||||
|
yj <- switch(tolower(substr(axis_title_just, 2, 2)), b = 0, l = 0, m = 0.5, c = 0.5, r = 1, t = 1) |
||||
|
|
||||
|
ret + |
||||
|
theme( |
||||
|
axis.text.x = element_text(size = axis_text_size, margin = margin(t = 0), lineheight = line_height), |
||||
|
axis.text.x.top = element_text(size = axis_text_size, margin = margin(t = 0), lineheight = line_height), |
||||
|
axis.text.x.bottom = element_text(size = axis_text_size, margin = margin(t = 0), lineheight = line_height), |
||||
|
|
||||
|
axis.text.y = element_text(size = axis_text_size, margin = margin(r = 0), lineheight = line_height), |
||||
|
axis.text.y.left = element_text(size = axis_text_size, margin = margin(r = 0), lineheight = line_height), |
||||
|
axis.text.y.right = element_text(size = axis_text_size, margin = margin(r = 0), lineheight = line_height), |
||||
|
|
||||
|
axis.title = element_text( |
||||
|
size = axis_title_size, |
||||
|
family = axis_title_family, lineheight = line_height |
||||
|
), |
||||
|
|
||||
|
axis.title.x = element_text( |
||||
|
hjust = xj, size = axis_title_size, |
||||
|
family = axis_title_family, lineheight = line_height |
||||
|
), |
||||
|
axis.title.x.top = element_text( |
||||
|
hjust = xj, size = axis_title_size, |
||||
|
family = axis_title_family, lineheight = line_height |
||||
|
), |
||||
|
axis.title.x.bottom = element_text( |
||||
|
hjust = xj, size = axis_title_size, |
||||
|
family = axis_title_family, lineheight = line_height |
||||
|
), |
||||
|
|
||||
|
axis.title.y = element_text( |
||||
|
hjust = yj, size = axis_title_size, |
||||
|
family = axis_title_family, lineheight = line_height |
||||
|
), |
||||
|
axis.title.y.left = element_text( |
||||
|
hjust = yj, size = axis_title_size, |
||||
|
family = axis_title_family, lineheight = line_height |
||||
|
), |
||||
|
axis.title.y.right = element_text( |
||||
|
hjust = yj, size = axis_title_size, angle = 90, |
||||
|
family = axis_title_family, lineheight = line_height |
||||
|
), |
||||
|
|
||||
|
strip.placement = strip_placement, |
||||
|
strip.text = element_text( |
||||
|
hjust = 0, size = strip_text_size, color = foreground_colour, |
||||
|
family = strip_text_family, lineheight = line_height |
||||
|
), |
||||
|
strip.text.x = element_text( |
||||
|
hjust = 0, size = strip_text_size, color = foreground_colour, |
||||
|
family = strip_text_family, lineheight = line_height |
||||
|
), |
||||
|
strip.background = element_rect( |
||||
|
fill = background_colour, color = NA |
||||
|
), |
||||
|
strip.background.x = element_rect( |
||||
|
fill = background_colour, color = NA |
||||
|
), |
||||
|
strip.background.y = element_rect( |
||||
|
fill = background_colour, color = NA |
||||
|
), |
||||
|
strip.text.y = element_text( |
||||
|
hjust = 0, size = strip_text_size, color = foreground_colour, |
||||
|
family = strip_text_family, lineheight = line_height |
||||
|
), |
||||
|
panel.spacing = panel_spacing, |
||||
|
panel.background = element_rect(color = NA, fill = background_colour), |
||||
|
plot.background = element_rect(color = NA, fill = background_colour), |
||||
|
plot.title.position = plot_title_position, |
||||
|
plot.margin = plot_margin, |
||||
|
plot.title = element_text( |
||||
|
hjust = 0, size = plot_title_size, margin = margin(b = plot_title_margin), |
||||
|
family = plot_title_family, lineheight = line_height |
||||
|
), |
||||
|
plot.subtitle = element_text( |
||||
|
hjust = 0, size = subtitle_size, margin = margin(b = subtitle_margin), |
||||
|
family = subtitle_family, lineheight = line_height |
||||
|
), |
||||
|
plot.caption = element_text( |
||||
|
hjust = 1, size = caption_size, margin = margin(t = caption_margin), |
||||
|
family = caption_family, lineheight = line_height |
||||
|
), |
||||
|
) -> ret |
||||
|
|
||||
|
ret |
||||
|
|
||||
|
} |
@ -0,0 +1,11 @@ |
|||||
|
#' Pipe operator |
||||
|
#' |
||||
|
#' See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details. |
||||
|
#' |
||||
|
#' @name %>% |
||||
|
#' @rdname pipe |
||||
|
#' @keywords internal |
||||
|
#' @export |
||||
|
#' @importFrom magrittr %>% |
||||
|
#' @usage lhs \%>\% rhs |
||||
|
NULL |
@ -0,0 +1,110 @@ |
|||||
|
#' Inter Font Variant |
||||
|
#' |
||||
|
#' On load hrbragg creates a custom Inter font family variant |
||||
|
#' and makes it available in the global environment. |
||||
|
#' |
||||
|
#' The reconfigured family variant has the following features: |
||||
|
#' |
||||
|
#' - `calt`: (_Contextual Alternates_): Applies a second substitution feature |
||||
|
#' based on a match of a character pattern within a context of surrounding patterns |
||||
|
#' - `case` (_Case Sensitive Forms_): Replace characters, especially punctuation, with forms better suited for all-capital text, cf. titl |
||||
|
#' - `dlig`/`ligatures` (_Discretionary Ligatures_): Ligatures to be applied at the user's discretion |
||||
|
#' - `kern` (_Kerning_): Fine horizontal positioning of one glyph to the next, based on the shapes of the glyphs |
||||
|
#' - `salt` (_Stylistic Alternates_): **DISABLED** — Either replaces with, or displays list of, stylistic alternatives for a character |
||||
|
#' - `ss01` (_Stylistic set 1: Alternate digits_): An alternate style of digits. |
||||
|
#' - `tnum` (_Tabular Figures_): Replaces numerals with glyphs of uniform width, often also lnum |
||||
|
#' - `zero` (_Slashed Zero_): **DISABLED** — Replaces 0 figure with slashed 0 |
||||
|
#' |
||||
|
#' Inter online documentation has [specific descriptions and examples of these features](https://rsms.me/inter/#features). |
||||
|
#' |
||||
|
#' This object has the following names corresponding to individual, |
||||
|
#' customized font variants (ordered by font weight): |
||||
|
#' |
||||
|
#' - `ultralight` |
||||
|
#' - `ultralight_italic` |
||||
|
#' - `light` |
||||
|
#' - `light_italic` |
||||
|
#' - `normal_italic` |
||||
|
#' - `normal` |
||||
|
#' - `medium_italic` |
||||
|
#' - `medium` |
||||
|
#' - `semibold_italic` |
||||
|
#' - `semibold` |
||||
|
#' - `bold` |
||||
|
#' - `bold_italic` |
||||
|
#' - `ultrabold` |
||||
|
#' - `ultrabold_italic` |
||||
|
#' - `heavy` |
||||
|
#' - `heavy_italic` |
||||
|
#' |
||||
|
#' @docType data |
||||
|
#' @format A list |
||||
|
#' @export |
||||
|
inter_pkg <- NULL |
||||
|
|
||||
|
|
||||
|
#' Robot Condensed Font Variant |
||||
|
#' |
||||
|
#' On load hrbragg creates a custom Roboto Condensed font family variant |
||||
|
#' and makes it available in the global environment. |
||||
|
#' |
||||
|
#' The reconfigured family variant has the following features: |
||||
|
#' |
||||
|
#' - `ccmp` (_Glyph Composition/Decomposition_): Either calls a ligature replacement |
||||
|
#' on a sequence of characters or replaces a character with a sequence of glyphs. |
||||
|
#' Provides logic that can for example effectively alter the order of input characters. |
||||
|
#' - `liga`/`ligatures` (_Standard Ligatures_): Replaces (by default) sequence of characters with a single ligature glyph |
||||
|
#' - `kern` (_Kerning_): Fine horizontal positioning of one glyph to the next, based on the shapes of the glyphs |
||||
|
#' - `tnum` (_Tabular Figures_): Replaces numerals with glyphs of uniform width, often also lnum |
||||
|
#' |
||||
|
#' Roboto Condensed |
||||
|
#' [font family preview/info](https://fonts.google.com/specimen/Roboto+Condensed) |
||||
|
#' |
||||
|
#' This object has the following names corresponding to individual, |
||||
|
#' customized font variants (ordered by font weight): |
||||
|
#' |
||||
|
#' - `normal_light` |
||||
|
#' - `normal` |
||||
|
#' - `normal_italic` |
||||
|
#' - `bold` |
||||
|
#' |
||||
|
#' @docType data |
||||
|
#' @format A list |
||||
|
#' @export |
||||
|
rc_pkg <- NULL |
||||
|
|
||||
|
#' Goldman Sans & Goldman Sans Condensed Font Variants |
||||
|
#' |
||||
|
#' On load hrbragg creates a custom Goldman Sans & Goldman Sans Condensed |
||||
|
#' font family variants and makes them available in the global environment. |
||||
|
#' |
||||
|
#' The reconfigured family variant has the following features: |
||||
|
#' |
||||
|
#' This object has the following names corresponding to individual, |
||||
|
#' customized font variants (ordered by font weight): |
||||
|
#' |
||||
|
#' **Goldman Sans** (`gs_rc`) |
||||
|
#' |
||||
|
#' - `light` |
||||
|
#' - `normal_italic` |
||||
|
#' - `normal_light` |
||||
|
#' - `medium` |
||||
|
#' - `medium_italic` |
||||
|
#' - `bold` |
||||
|
#' - `bold_italic` |
||||
|
#' - `heavy` |
||||
|
#' |
||||
|
#' **Goldman Sans Condensed** (`gsc_rc`) |
||||
|
#' |
||||
|
#' - `normal` |
||||
|
#' - `bold` |
||||
|
#' |
||||
|
#' @docType data |
||||
|
#' @format A list |
||||
|
#' @export |
||||
|
gs_pkg <- NULL |
||||
|
|
||||
|
#' @docType data |
||||
|
#' @format A list |
||||
|
#' @export |
||||
|
gsc_pkg <- NULL |
After Width: | Height: | Size: 412 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 60 KiB |
After Width: | Height: | Size: 60 KiB |
Before Width: | Height: | Size: 66 KiB After Width: | Height: | Size: 155 KiB |
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 62 KiB |
After Width: | Height: | Size: 59 KiB |
After Width: | Height: | Size: 59 KiB |
Before Width: | Height: | Size: 68 KiB After Width: | Height: | Size: 159 KiB |
After Width: | Height: | Size: 328 KiB |
After Width: | Height: | Size: 22 KiB |
After Width: | Height: | Size: 229 KiB |
@ -0,0 +1,41 @@ |
|||||
|
% Generated by roxygen2: do not edit by hand |
||||
|
% Please edit documentation in R/x-font-reg.R |
||||
|
\docType{data} |
||||
|
\name{gs_pkg} |
||||
|
\alias{gs_pkg} |
||||
|
\title{Goldman Sans & Goldman Sans Condensed Font Variants} |
||||
|
\format{ |
||||
|
A list |
||||
|
} |
||||
|
\usage{ |
||||
|
gs_pkg |
||||
|
} |
||||
|
\description{ |
||||
|
On load hrbragg creates a custom Goldman Sans & Goldman Sans Condensed |
||||
|
font family variants and makes them available in the global environment. |
||||
|
} |
||||
|
\details{ |
||||
|
The reconfigured family variant has the following features: |
||||
|
|
||||
|
This object has the following names corresponding to individual, |
||||
|
customized font variants (ordered by font weight): |
||||
|
|
||||
|
\strong{Goldman Sans} (\code{gs_rc}) |
||||
|
\itemize{ |
||||
|
\item \code{light} |
||||
|
\item \code{normal_italic} |
||||
|
\item \code{normal_light} |
||||
|
\item \code{medium} |
||||
|
\item \code{medium_italic} |
||||
|
\item \code{bold} |
||||
|
\item \code{bold_italic} |
||||
|
\item \code{heavy} |
||||
|
} |
||||
|
|
||||
|
\strong{Goldman Sans Condensed} (\code{gsc_rc}) |
||||
|
\itemize{ |
||||
|
\item \code{normal} |
||||
|
\item \code{bold} |
||||
|
} |
||||
|
} |
||||
|
\keyword{datasets} |
@ -0,0 +1,23 @@ |
|||||
|
% Generated by roxygen2: do not edit by hand |
||||
|
% Please edit documentation in R/install-fonts.R |
||||
|
\name{install_goldman_sans} |
||||
|
\alias{install_goldman_sans} |
||||
|
\title{Install Goldman Sans (Condensed)} |
||||
|
\usage{ |
||||
|
install_goldman_sans() |
||||
|
} |
||||
|
\description{ |
||||
|
Goldman Sans is a clean, modern typeface designed for dense data-rich |
||||
|
environments. From open letter shapes, enlarged x-height, and optical |
||||
|
balancing of individual letterforms, we designed Goldman Sans with |
||||
|
clarity in mind. Both normal and condensed versions are provided. |
||||
|
} |
||||
|
\note{ |
||||
|
\href{https://design.gs.com/d/legal/goldman-sans-license}{Goldman Sans Restricted Font License} |
||||
|
} |
||||
|
\examples{ |
||||
|
install_goldman_sans() |
||||
|
} |
||||
|
\references{ |
||||
|
\href{https://design.gs.com/d/story/goldman-sans/}{Goldman Sans} |
||||
|
} |
@ -0,0 +1,22 @@ |
|||||
|
% Generated by roxygen2: do not edit by hand |
||||
|
% Please edit documentation in R/install-fonts.R |
||||
|
\name{install_roboto_condensed} |
||||
|
\alias{install_roboto_condensed} |
||||
|
\title{Install Roboto Condensed} |
||||
|
\usage{ |
||||
|
install_roboto_condensed() |
||||
|
} |
||||
|
\description{ |
||||
|
Roboto has a dual nature. It has a mechanical skeleton and the forms are |
||||
|
largely geometric. At the same time, the font features friendly and open |
||||
|
curves. While some grotesks distort their letterforms to force a rigid rhythm, |
||||
|
Roboto doesn’t compromise, allowing letters to be settled into their natural |
||||
|
width. This makes for a more natural reading rhythm more commonly found in |
||||
|
humanist and serif types. |
||||
|
} |
||||
|
\note{ |
||||
|
\href{http://www.apache.org/licenses/LICENSE-2.0}{Apache License, Version 2.0.} |
||||
|
} |
||||
|
\examples{ |
||||
|
install_roboto_condensed() |
||||
|
} |
@ -0,0 +1,12 @@ |
|||||
|
% Generated by roxygen2: do not edit by hand |
||||
|
% Please edit documentation in R/utils-pipe.R |
||||
|
\name{\%>\%} |
||||
|
\alias{\%>\%} |
||||
|
\title{Pipe operator} |
||||
|
\usage{ |
||||
|
lhs \%>\% rhs |
||||
|
} |
||||
|
\description{ |
||||
|
See \code{magrittr::\link[magrittr:pipe]{\%>\%}} for details. |
||||
|
} |
||||
|
\keyword{internal} |
@ -0,0 +1,51 @@ |
|||||
|
% Generated by roxygen2: do not edit by hand |
||||
|
% Please edit documentation in R/preview-variant.R |
||||
|
\name{preview_variant} |
||||
|
\alias{preview_variant} |
||||
|
\title{Preview numbers, kerning, and ligatures from font variants you create} |
||||
|
\usage{ |
||||
|
preview_variant( |
||||
|
font_variant, |
||||
|
font_size = 5, |
||||
|
|
||||
|
test_label = "Lorem Ipsum dolor sit amet consectetur. => A\\u20dd\\n−0+1:2~3,456789\\n−9+8:7~6,543210" |
||||
|
) |
||||
|
} |
||||
|
\arguments{ |
||||
|
\item{font_variant}{a font variant object created with \code{\link[=reconfigure_font]{reconfigure_font()}}} |
||||
|
|
||||
|
\item{font_size}{passed to \code{\link[ggplot2:geom_text]{ggplot2::geom_text()}}} |
||||
|
|
||||
|
\item{test_label}{a specially designed preview string to showcase some |
||||
|
specific font features} |
||||
|
} |
||||
|
\value{ |
||||
|
A ggplot2 object |
||||
|
} |
||||
|
\description{ |
||||
|
Use this function to preview the special features of fonts you create |
||||
|
including how well the default kerning ruls work, how tabular numbers |
||||
|
behave, and whether or not modern, fun ligatures are supported. Change |
||||
|
the \code{test_label} if you wish to use a custom preview string. |
||||
|
} |
||||
|
\examples{ |
||||
|
reconfigure_font( |
||||
|
family = "Trattatello", |
||||
|
width = "normal", |
||||
|
ligatures = "discretionary", |
||||
|
calt = 1, tnum = 1, case = 1, |
||||
|
dlig = 1, kern = 1, |
||||
|
zero = 0, salt = 0 |
||||
|
) -> trat |
||||
|
|
||||
|
preview_variant(trat) |
||||
|
|
||||
|
reconfigure_font( |
||||
|
family = "Barlow", |
||||
|
width = "normal", |
||||
|
ligatures = "standard", |
||||
|
tnum = 1, kern = 1 |
||||
|
) -> barlow |
||||
|
|
||||
|
preview_variant(barlow) |
||||
|
} |
@ -0,0 +1,40 @@ |
|||||
|
% Generated by roxygen2: do not edit by hand |
||||
|
% Please edit documentation in R/x-font-reg.R |
||||
|
\docType{data} |
||||
|
\name{rc_pkg} |
||||
|
\alias{rc_pkg} |
||||
|
\title{Robot Condensed Font Variant} |
||||
|
\format{ |
||||
|
A list |
||||
|
} |
||||
|
\usage{ |
||||
|
rc_pkg |
||||
|
} |
||||
|
\description{ |
||||
|
On load hrbragg creates a custom Roboto Condensed font family variant |
||||
|
and makes it available in the global environment. |
||||
|
} |
||||
|
\details{ |
||||
|
The reconfigured family variant has the following features: |
||||
|
\itemize{ |
||||
|
\item \code{ccmp} (\emph{Glyph Composition/Decomposition}): Either calls a ligature replacement |
||||
|
on a sequence of characters or replaces a character with a sequence of glyphs. |
||||
|
Provides logic that can for example effectively alter the order of input characters. |
||||
|
\item \code{liga}/\code{ligatures} (\emph{Standard Ligatures}): Replaces (by default) sequence of characters with a single ligature glyph |
||||
|
\item \code{kern} (\emph{Kerning}): Fine horizontal positioning of one glyph to the next, based on the shapes of the glyphs |
||||
|
\item \code{tnum} (\emph{Tabular Figures}): Replaces numerals with glyphs of uniform width, often also lnum |
||||
|
} |
||||
|
|
||||
|
Roboto Condensed |
||||
|
\href{https://fonts.google.com/specimen/Roboto+Condensed}{font family preview/info} |
||||
|
|
||||
|
This object has the following names corresponding to individual, |
||||
|
customized font variants (ordered by font weight): |
||||
|
\itemize{ |
||||
|
\item \code{normal_light} |
||||
|
\item \code{normal} |
||||
|
\item \code{normal_italic} |
||||
|
\item \code{bold} |
||||
|
} |
||||
|
} |
||||
|
\keyword{datasets} |
@ -0,0 +1,11 @@ |
|||||
|
% Generated by roxygen2: do not edit by hand |
||||
|
% Please edit documentation in R/reset-ggplot2-defaults.R |
||||
|
\name{reset_ggplot2_defaults} |
||||
|
\alias{reset_ggplot2_defaults} |
||||
|
\title{Restore all ggplot2 geom to default aesthetics} |
||||
|
\usage{ |
||||
|
reset_ggplot2_defaults() |
||||
|
} |
||||
|
\description{ |
||||
|
Restore all ggplot2 geom to default aesthetics |
||||
|
} |
@ -0,0 +1,172 @@ |
|||||
|
% Generated by roxygen2: do not edit by hand |
||||
|
% Please edit documentation in R/scales.R |
||||
|
\name{scale_x_percent} |
||||
|
\alias{scale_x_percent} |
||||
|
\alias{scale_y_percent} |
||||
|
\alias{scale_x_comma} |
||||
|
\alias{scale_y_comma} |
||||
|
\title{X & Y scales with opinionated pre-sets for percent & comma label formats} |
||||
|
\usage{ |
||||
|
scale_x_percent( |
||||
|
name = waiver(), |
||||
|
breaks = waiver(), |
||||
|
minor_breaks = waiver(), |
||||
|
guide = waiver(), |
||||
|
n.breaks = NULL, |
||||
|
labels, |
||||
|
limits = NULL, |
||||
|
expand = c(0.01, 0), |
||||
|
oob = censor, |
||||
|
na.value = NA_real_, |
||||
|
trans = "identity", |
||||
|
position = "bottom", |
||||
|
sec.axis = waiver(), |
||||
|
accuracy = 1, |
||||
|
scale = 100, |
||||
|
prefix = "", |
||||
|
suffix = "\%", |
||||
|
big.mark = " ", |
||||
|
decimal.mark = ".", |
||||
|
trim = TRUE, |
||||
|
... |
||||
|
) |
||||
|
|
||||
|
scale_y_percent( |
||||
|
name = waiver(), |
||||
|
breaks = waiver(), |
||||
|
minor_breaks = waiver(), |
||||
|
guide = waiver(), |
||||
|
n.breaks = NULL, |
||||
|
labels, |
||||
|
limits = NULL, |
||||
|
expand = c(0.01, 0), |
||||
|
oob = censor, |
||||
|
na.value = NA_real_, |
||||
|
trans = "identity", |
||||
|
position = "left", |
||||
|
sec.axis = waiver(), |
||||
|
accuracy = 1, |
||||
|
scale = 100, |
||||
|
prefix = "", |
||||
|
suffix = "\%", |
||||
|
big.mark = " ", |
||||
|
decimal.mark = ".", |
||||
|
trim = TRUE, |
||||
|
... |
||||
|
) |
||||
|
|
||||
|
scale_x_comma( |
||||
|
name = waiver(), |
||||
|
breaks = waiver(), |
||||
|
minor_breaks = waiver(), |
||||
|
guide = waiver(), |
||||
|
n.breaks = NULL, |
||||
|
labels, |
||||
|
limits = NULL, |
||||
|
expand = c(0.01, 0), |
||||
|
oob = censor, |
||||
|
na.value = NA_real_, |
||||
|
trans = "identity", |
||||
|
position = "bottom", |
||||
|
sec.axis = waiver(), |
||||
|
accuracy = 1, |
||||
|
scale = 1, |
||||
|
prefix = "", |
||||
|
suffix = "", |
||||
|
big.mark = ",", |
||||
|
decimal.mark = ".", |
||||
|
trim = TRUE, |
||||
|
... |
||||
|
) |
||||
|
|
||||
|
scale_y_comma( |
||||
|
name = waiver(), |
||||
|
breaks = waiver(), |
||||
|
minor_breaks = waiver(), |
||||
|
guide = waiver(), |
||||
|
n.breaks = NULL, |
||||
|
labels, |
||||
|
limits = NULL, |
||||
|
expand = c(0.01, 0), |
||||
|
oob = censor, |
||||
|
na.value = NA_real_, |
||||
|
trans = "identity", |
||||
|
position = "left", |
||||
|
sec.axis = waiver(), |
||||
|
accuracy = 1, |
||||
|
scale = 1, |
||||
|
prefix = "", |
||||
|
suffix = "", |
||||
|
big.mark = ",", |
||||
|
decimal.mark = ".", |
||||
|
trim = TRUE, |
||||
|
... |
||||
|
) |
||||
|
} |
||||
|
\arguments{ |
||||
|
\item{name}{The name of the scale. Used as axis or legend title. If |
||||
|
\code{waiver()}, the default, the name of the scale is taken from the first |
||||
|
mapping used for that aesthetic. If \code{NULL}, the legend title will be |
||||
|
omitted.} |
||||
|
|
||||
|
\item{breaks}{One of: |
||||
|
\itemize{ |
||||
|
\item \code{NULL} for no breaks |
||||
|
\item \code{waiver()} for the default breaks computed by the |
||||
|
transformation object |
||||
|
\item A numeric vector of positions |
||||
|
\item A function that takes the limits as input and returns breaks |
||||
|
as output |
||||
|
}} |
||||
|
|
||||
|
\item{minor_breaks}{One of: |
||||
|
\itemize{ |
||||
|
\item \code{NULL} for no minor breaks |
||||
|
\item \code{waiver()} for the default breaks (one minor break between |
||||
|
each major break) |
||||
|
\item A numeric vector of positions |
||||
|
\item A function that given the limits returns a vector of minor breaks. |
||||
|
}} |
||||
|
|
||||
|
\item{guide}{guide A function used to create a guide or its name. See \code{\link[=guides]{guides()}} for more information.} |
||||
|
|
||||
|
\item{n.breaks}{An integer guiding the number of major breaks. The algorithm may choose a |
||||
|
slightly different number to ensure nice break labels. Will only have an effect if |
||||
|
\code{breaks = waiver()}. Use NULL to use the default number of breaks given by the transformation.} |
||||
|
|
||||
|
\item{labels}{Specifying overrides the default format (i.e. you really don't |
||||
|
want to do that). \code{NULL} means no labels.} |
||||
|
|
||||
|
\item{limits}{A numeric vector of length two providing limits of the scale. |
||||
|
Use \code{NA} to refer to the existing minimum or maximum.} |
||||
|
|
||||
|
\item{expand}{same as in ggplot2} |
||||
|
|
||||
|
\item{oob}{Function that handles limits outside of the scale limits |
||||
|
(out of bounds). The default replaces out of bounds values with NA.} |
||||
|
|
||||
|
\item{na.value}{If \code{na.translate = TRUE}, what value aesthetic |
||||
|
value should missing be displayed as? Does not apply to position scales |
||||
|
where \code{NA} is always placed at the far right.} |
||||
|
|
||||
|
\item{trans}{Either the name of a transformation object, or the |
||||
|
object itself. Built-in transformations include "asn", "atanh", |
||||
|
"boxcox", "exp", "identity", "log", "log10", "log1p", "log2", |
||||
|
"logit", "probability", "probit", "reciprocal", "reverse" and "sqrt".} |
||||
|
|
||||
|
\item{position}{The position of the axis. "left" or "right" for vertical |
||||
|
scales, "top" or "bottom" for horizontal scales} |
||||
|
|
||||
|
\item{sec.axis}{specify a secondary axis} |
||||
|
|
||||
|
\item{accuracy, scale, prefix, suffix, big.mark, decimal.mark, trim}{See |
||||
|
\code{\link[scales:label_number]{scales::comma_format()}} or \code{\link[scales:label_percent]{scales::percent_format()}}} |
||||
|
|
||||
|
\item{...}{passed on to \code{\link[scales:label_number]{scales::comma_format()}} or \code{\link[scales:label_percent]{scales::percent_format()}}} |
||||
|
} |
||||
|
\description{ |
||||
|
The \verb{_comma} ones set comma format for axis text and \code{expand=c(0,0)} (you need to set limits). |
||||
|
} |
||||
|
\details{ |
||||
|
The \verb{_percent} ones set precent format for axis text and \code{expand=c(0,0)} (you need to set limits). |
||||
|
} |
@ -0,0 +1,117 @@ |
|||||
|
% Generated by roxygen2: do not edit by hand |
||||
|
% Please edit documentation in R/theme-gs.R |
||||
|
\name{theme_gs} |
||||
|
\alias{theme_gs} |
||||
|
\title{ggplot2 Theme Based On The Goldman Sans Font Family} |
||||
|
\usage{ |
||||
|
theme_gs( |
||||
|
base_size = 11.5, |
||||
|
line_height = 0.875, |
||||
|
plot_title_size = 18, |
||||
|
plot_title_position = "panel", |
||||
|
plot_title_margin = 10, |
||||
|
subtitle_size = 12, |
||||
|
subtitle_margin = 12, |
||||
|
strip_text_size = 12, |
||||
|
strip_placement = "outer", |
||||
|
caption_size = 10, |
||||
|
caption_margin = 10, |
||||
|
axis_text_size = base_size, |
||||
|
axis_title_size = 10, |
||||
|
axis_title_just = "rt", |
||||
|
panel_spacing = grid::unit(2, "lines"), |
||||
|
plot_margin = margin(30, 30, 30, 30), |
||||
|
mode = c("light", "dark", "rstudio"), |
||||
|
background_colour = theme_background_color(mode, light = "white", dark = "#121212"), |
||||
|
foreground_colour = theme_foreground_color(mode, light = "#262626", dark = "#e1e1e1"), |
||||
|
grid_col = theme_foreground_color(mode, light = "#cccccc", dark = "#606367"), |
||||
|
axis_col = theme_foreground_color(mode, light = "#2b2b2b", dark = "#606367"), |
||||
|
grid = TRUE, |
||||
|
axis = FALSE, |
||||
|
ticks = FALSE |
||||
|
) |
||||
|
} |
||||
|
\arguments{ |
||||
|
\item{base_size}{base font size} |
||||
|
|
||||
|
\item{line_height}{default line height} |
||||
|
|
||||
|
\item{plot_title_size}{plot title size} |
||||
|
|
||||
|
\item{plot_title_position}{plot title position} |
||||
|
|
||||
|
\item{plot_title_margin}{plot title margin} |
||||
|
|
||||
|
\item{subtitle_size}{subtitle size} |
||||
|
|
||||
|
\item{subtitle_margin}{subtitle margin} |
||||
|
|
||||
|
\item{strip_text_size}{strip text size} |
||||
|
|
||||
|
\item{strip_placement}{strip placement} |
||||
|
|
||||
|
\item{caption_size}{caption size} |
||||
|
|
||||
|
\item{caption_margin}{caption margin} |
||||
|
|
||||
|
\item{axis_text_size}{axis text size} |
||||
|
|
||||
|
\item{axis_title_size}{axis title size} |
||||
|
|
||||
|
\item{axis_title_just}{axis title just} |
||||
|
|
||||
|
\item{panel_spacing}{panel spacing} |
||||
|
|
||||
|
\item{plot_margin}{plot margin} |
||||
|
|
||||
|
\item{grid_col}{grid col} |
||||
|
|
||||
|
\item{axis_col}{axis col} |
||||
|
|
||||
|
\item{grid}{grid} |
||||
|
|
||||
|
\item{axis}{axis} |
||||
|
|
||||
|
\item{ticks}{ticks} |
||||
|
|
||||
|
\item{text_geom_size}{text geom size} |
||||
|
} |
||||
|
\value{ |
||||
|
ggplot2 theme |
||||
|
} |
||||
|
\description{ |
||||
|
Uses the built-in \link{gs_pkg} custom font. |
||||
|
} |
||||
|
\details{ |
||||
|
\itemize{ |
||||
|
\item \code{background_colour} dark mode is "\verb{#121212}" else "\code{white}" |
||||
|
\item \code{foreground_colour} dark mode is "\verb{#e1e1e1}" else "\verb{#262626}" |
||||
|
\item \code{grid_col} dark mode is "\verb{#606367}" else "\verb{#cccccc}" |
||||
|
\item \code{axis_col} dark mode is "\verb{#606367}" else "\verb{#2b2b2b}" |
||||
|
} |
||||
|
} |
||||
|
\note{ |
||||
|
this function updates \code{Geom} defaults; use \code{\link[=reset_ggplot2_defaults]{reset_ggplot2_defaults()}} to |
||||
|
restore ggplot2 geom default aeshetics |
||||
|
} |
||||
|
\examples{ |
||||
|
ggplot() + |
||||
|
geom_point( |
||||
|
data = mtcars, |
||||
|
aes(mpg, wt) |
||||
|
) + |
||||
|
geom_label( |
||||
|
aes( |
||||
|
x = 30, y = 4.5, |
||||
|
label = "A fairly useless\nannotation that\nuses the custom\nInter variant\nby default." |
||||
|
), |
||||
|
label.size = 0 |
||||
|
) + |
||||
|
labs( |
||||
|
x = "Fuel efficiency (mpg)", y = "Weight (tons)", |
||||
|
title = "Seminal ggplot2 scatterplot example", |
||||
|
subtitle = "A plot that is only useful for demonstration purposes", |
||||
|
caption = "Brought to you by the letter 'g'" |
||||
|
) + |
||||
|
theme_gs(grid = "XY") |
||||
|
} |
@ -0,0 +1,117 @@ |
|||||
|
% Generated by roxygen2: do not edit by hand |
||||
|
% Please edit documentation in R/theme-rc.R |
||||
|
\name{theme_rc} |
||||
|
\alias{theme_rc} |
||||
|
\title{ggplot2 Theme Based On The Roboto Condensed Font Family} |
||||
|
\usage{ |
||||
|
theme_rc( |
||||
|
base_size = 10, |
||||
|
line_height = 0.875, |
||||
|
plot_title_size = 18, |
||||
|
plot_title_position = "panel", |
||||
|
plot_title_margin = 10, |
||||
|
subtitle_size = 12, |
||||
|
subtitle_margin = 12, |
||||
|
strip_text_size = 12, |
||||
|
strip_placement = "outer", |
||||
|
caption_size = 9, |
||||
|
caption_margin = 10, |
||||
|
axis_text_size = base_size, |
||||
|
axis_title_size = 9, |
||||
|
axis_title_just = "rt", |
||||
|
panel_spacing = grid::unit(2, "lines"), |
||||
|
plot_margin = margin(30, 30, 30, 30), |
||||
|
mode = c("light", "dark", "rstudio"), |
||||
|
background_colour = theme_background_color(mode, light = "white", dark = "#121212"), |
||||
|
foreground_colour = theme_foreground_color(mode, light = "#262626", dark = "#e1e1e1"), |
||||
|
grid_col = theme_foreground_color(mode, light = "#cccccc", dark = "#606367"), |
||||
|
axis_col = theme_foreground_color(mode, light = "#2b2b2b", dark = "#606367"), |
||||
|
grid = TRUE, |
||||
|
axis = FALSE, |
||||
|
ticks = FALSE |
||||
|
) |
||||
|
} |
||||
|
\arguments{ |
||||
|
\item{base_size}{base font size} |
||||
|
|
||||
|
\item{line_height}{default line height} |
||||
|
|
||||
|
\item{plot_title_size}{plot title size} |
||||
|
|
||||
|
\item{plot_title_position}{plot title position} |
||||
|
|
||||
|
\item{plot_title_margin}{plot title margin} |
||||
|
|
||||
|
\item{subtitle_size}{subtitle size} |
||||
|
|
||||
|
\item{subtitle_margin}{subtitle margin} |
||||
|
|
||||
|
\item{strip_text_size}{strip text size} |
||||
|
|
||||
|
\item{strip_placement}{strip placement} |
||||
|
|
||||
|
\item{caption_size}{caption size} |
||||
|
|
||||
|
\item{caption_margin}{caption margin} |
||||
|
|
||||
|
\item{axis_text_size}{axis text size} |
||||
|
|
||||
|
\item{axis_title_size}{axis title size} |
||||
|
|
||||
|
\item{axis_title_just}{axis title just} |
||||
|
|
||||
|
\item{panel_spacing}{panel spacing} |
||||
|
|
||||
|
\item{plot_margin}{plot margin} |
||||
|
|
||||
|
\item{grid_col}{grid col} |
||||
|
|
||||
|
\item{axis_col}{axis col} |
||||
|
|
||||
|
\item{grid}{grid} |
||||
|
|
||||
|
\item{axis}{axis} |
||||
|
|
||||
|
\item{ticks}{ticks} |
||||
|
|
||||
|
\item{text_geom_size}{text geom size} |
||||
|
} |
||||
|
\value{ |
||||
|
ggplot2 theme |
||||
|
} |
||||
|
\description{ |
||||
|
Uses the built-in \link{rc_pkg} custom font. |
||||
|
} |
||||
|
\details{ |
||||
|
\itemize{ |
||||
|
\item \code{background_colour} dark mode is "\verb{#121212}" else "\code{white}" |
||||
|
\item \code{foreground_colour} dark mode is "\verb{#e1e1e1}" else "\verb{#262626}" |
||||
|
\item \code{grid_col} dark mode is "\verb{#606367}" else "\verb{#cccccc}" |
||||
|
\item \code{axis_col} dark mode is "\verb{#606367}" else "\verb{#2b2b2b}" |
||||
|
} |
||||
|
} |
||||
|
\note{ |
||||
|
this function updates \code{Geom} defaults; use \code{\link[=reset_ggplot2_defaults]{reset_ggplot2_defaults()}} to |
||||
|
restore ggplot2 geom default aeshetics |
||||
|
} |
||||
|
\examples{ |
||||
|
ggplot() + |
||||
|
geom_point( |
||||
|
data = mtcars, |
||||
|
aes(mpg, wt) |
||||
|
) + |
||||
|
geom_label( |
||||
|
aes( |
||||
|
x = 30, y = 4.5, |
||||
|
label = "A fairly useless\nannotation that\nuses the custom\nInter variant\nby default." |
||||
|
), |
||||
|
label.size = 0 |
||||
|
) + |
||||
|
labs( |
||||
|
x = "Fuel efficiency (mpg)", y = "Weight (tons)", |
||||
|
title = "Seminal ggplot2 scatterplot example", |
||||
|
subtitle = "A plot that is only useful for demonstration purposes", |
||||
|
caption = "Brought to you by the letter 'g'" |
||||
|
) + |
||||
|
theme_rc(grid = "XY") |
||||
|
} |