Browse Source

minor theme tweaks

master
boB Rudis 3 years ago
parent
commit
643816d3a0
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 4
      DESCRIPTION
  2. 38
      R/finish-theme.R
  3. 3
      R/theme-gs.R
  4. 9
      R/theme-inter.R
  5. 3
      R/theme-rc.R
  6. 2
      man/preview_variant.Rd
  7. 3
      man/theme_gs.Rd
  8. 9
      man/theme_inter.Rd
  9. 3
      man/theme_rc.Rd

4
DESCRIPTION

@ -2,8 +2,8 @@ Package: hrbragg
Type: Package Type: Package
Title: Typography-centric Themes, Theme Components, and Utilities Title: Typography-centric Themes, Theme Components, and Utilities
for 'ggplot2' and 'ragg'. for 'ggplot2' and 'ragg'.
Version: 0.2.0 Version: 0.2.1
Date: 2021-02-16 Date: 2021-05-20
Authors@R: c( Authors@R: c(
person( person(
given = "Bob", given = "Bob",

38
R/finish-theme.R

@ -21,6 +21,7 @@ finish_theme <- function(base_size,
axis_col, axis_col,
grid, grid,
axis, axis,
axis_text = TRUE,
ticks, ticks,
base_family, base_family,
plot_title_family, plot_title_family,
@ -85,7 +86,10 @@ finish_theme <- function(base_size,
} }
} else { } else {
ret <- ret + theme(panel.grid = element_blank()) ret +
theme(
panel.grid = element_blank()
) -> ret
} }
if (inherits(axis, "character") | axis == TRUE) { if (inherits(axis, "character") | axis == TRUE) {
@ -134,16 +138,32 @@ finish_theme <- function(base_size,
xj <- switch(tolower(substr(axis_title_just, 1, 1)), b = 0, l = 0, m = 0.5, c = 0.5, r = 1, t = 1) 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) yj <- switch(tolower(substr(axis_title_just, 2, 2)), b = 0, l = 0, m = 0.5, c = 0.5, r = 1, t = 1)
ret + if (axis_text) {
theme( ret +
axis.text.x = element_text(size = axis_text_size, margin = margin(t = 0), lineheight = line_height), theme(
axis.text.x.top = element_text(size = axis_text_size, margin = margin(t = 0), lineheight = line_height), axis.text.x = 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.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)
) -> ret
} else {
ret +
theme(
axis.text.x = element_blank(),
axis.text.x.top = element_blank(),
axis.text.x.bottom = element_blank(),
axis.text.y = element_text(size = axis_text_size, margin = margin(r = 0), lineheight = line_height), axis.text.y = element_blank(),
axis.text.y.left = element_text(size = axis_text_size, margin = margin(r = 0), lineheight = line_height), axis.text.y.left = element_blank(),
axis.text.y.right = element_text(size = axis_text_size, margin = margin(r = 0), lineheight = line_height), axis.text.y.right = element_blank(),
) -> ret
}
ret +
theme(
axis.title = element_text( axis.title = element_text(
size = axis_title_size, size = axis_title_size,
family = axis_title_family, lineheight = line_height family = axis_title_family, lineheight = line_height

3
R/theme-gs.R

@ -30,6 +30,7 @@
#' @param grid grid #' @param grid grid
#' @param axis_col axis col #' @param axis_col axis col
#' @param axis axis #' @param axis axis
#' @param axis_text axis text labels
#' @param ticks ticks #' @param ticks ticks
#' @return ggplot2 theme #' @return ggplot2 theme
#' @export #' @export
@ -77,6 +78,7 @@ theme_gs <- function(
axis_col = theme_foreground_color(mode, light = "#2b2b2b", dark = "#606367"), axis_col = theme_foreground_color(mode, light = "#2b2b2b", dark = "#606367"),
grid = TRUE, grid = TRUE,
axis = FALSE, axis = FALSE,
axis_text = TRUE,
ticks = FALSE) { ticks = FALSE) {
base_family <- gsc_pkg$normal base_family <- gsc_pkg$normal
@ -111,6 +113,7 @@ theme_gs <- function(
axis_col = axis_col, axis_col = axis_col,
grid = grid, grid = grid,
axis = axis, axis = axis,
axis_text = axis_text,
ticks = ticks, ticks = ticks,
base_family = base_family, base_family = base_family,
plot_title_family = plot_title_family, plot_title_family = plot_title_family,

9
R/theme-inter.R

@ -30,6 +30,7 @@
#' @param grid grid #' @param grid grid
#' @param axis_col axis col #' @param axis_col axis col
#' @param axis axis #' @param axis axis
#' @param axis_text axis text labels
#' @param ticks ticks #' @param ticks ticks
#' @return ggplot2 theme #' @return ggplot2 theme
#' @export #' @export
@ -58,13 +59,13 @@ theme_inter <- function(
line_height = 0.875, line_height = 0.875,
plot_title_size = 18, plot_title_size = 18,
plot_title_position = "panel", plot_title_position = "panel",
plot_title_margin = 10, plot_title_margin = 8,
subtitle_size = 12, subtitle_size = 12,
subtitle_margin = 12, subtitle_margin = 10,
strip_text_size = 12, strip_text_size = 12,
strip_placement = "outer", strip_placement = "outer",
caption_size = 9, caption_size = 9,
caption_margin = 10, caption_margin = 8,
axis_text_size = base_size, axis_text_size = base_size,
axis_title_size = 9, axis_title_size = 9,
axis_title_just = "rt", axis_title_just = "rt",
@ -77,6 +78,7 @@ theme_inter <- function(
axis_col = theme_foreground_color(mode, light = "#2b2b2b", dark = "#606367"), axis_col = theme_foreground_color(mode, light = "#2b2b2b", dark = "#606367"),
grid = TRUE, grid = TRUE,
axis = FALSE, axis = FALSE,
axis_text = TRUE,
ticks = FALSE) { ticks = FALSE) {
base_family <- inter_pkg$normal base_family <- inter_pkg$normal
@ -111,6 +113,7 @@ theme_inter <- function(
axis_col = axis_col, axis_col = axis_col,
grid = grid, grid = grid,
axis = axis, axis = axis,
axis_text = axis_text,
ticks = ticks, ticks = ticks,
base_family = base_family, base_family = base_family,
plot_title_family = plot_title_family, plot_title_family = plot_title_family,

3
R/theme-rc.R

@ -30,6 +30,7 @@
#' @param grid grid #' @param grid grid
#' @param axis_col axis col #' @param axis_col axis col
#' @param axis axis #' @param axis axis
#' @param axis_text axis text labels
#' @param ticks ticks #' @param ticks ticks
#' @return ggplot2 theme #' @return ggplot2 theme
#' @export #' @export
@ -77,6 +78,7 @@ theme_rc <- function(
axis_col = theme_foreground_color(mode, light = "#2b2b2b", dark = "#606367"), axis_col = theme_foreground_color(mode, light = "#2b2b2b", dark = "#606367"),
grid = TRUE, grid = TRUE,
axis = FALSE, axis = FALSE,
axis_text = TRUE,
ticks = FALSE) { ticks = FALSE) {
base_family <- rc_pkg$normal base_family <- rc_pkg$normal
@ -111,6 +113,7 @@ theme_rc <- function(
axis_col = axis_col, axis_col = axis_col,
grid = grid, grid = grid,
axis = axis, axis = axis,
axis_text = axis_text,
ticks = ticks, ticks = ticks,
base_family = base_family, base_family = base_family,
plot_title_family = plot_title_family, plot_title_family = plot_title_family,

2
man/preview_variant.Rd

@ -8,7 +8,7 @@ preview_variant(
font_variant, font_variant,
font_size = 5, 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" test_label = "Lorem Ipsum dolor sit amet consectetur. => A\\n−0+1:2~3,456789\\n−9+8:7~6,543210"
) )
} }
\arguments{ \arguments{

3
man/theme_gs.Rd

@ -28,6 +28,7 @@ theme_gs(
axis_col = theme_foreground_color(mode, light = "#2b2b2b", dark = "#606367"), axis_col = theme_foreground_color(mode, light = "#2b2b2b", dark = "#606367"),
grid = TRUE, grid = TRUE,
axis = FALSE, axis = FALSE,
axis_text = TRUE,
ticks = FALSE ticks = FALSE
) )
} }
@ -72,6 +73,8 @@ theme_gs(
\item{axis}{axis} \item{axis}{axis}
\item{axis_text}{axis text labels}
\item{ticks}{ticks} \item{ticks}{ticks}
\item{text_geom_size}{text geom size} \item{text_geom_size}{text geom size}

9
man/theme_inter.Rd

@ -9,13 +9,13 @@ theme_inter(
line_height = 0.875, line_height = 0.875,
plot_title_size = 18, plot_title_size = 18,
plot_title_position = "panel", plot_title_position = "panel",
plot_title_margin = 10, plot_title_margin = 8,
subtitle_size = 12, subtitle_size = 12,
subtitle_margin = 12, subtitle_margin = 10,
strip_text_size = 12, strip_text_size = 12,
strip_placement = "outer", strip_placement = "outer",
caption_size = 9, caption_size = 9,
caption_margin = 10, caption_margin = 8,
axis_text_size = base_size, axis_text_size = base_size,
axis_title_size = 9, axis_title_size = 9,
axis_title_just = "rt", axis_title_just = "rt",
@ -28,6 +28,7 @@ theme_inter(
axis_col = theme_foreground_color(mode, light = "#2b2b2b", dark = "#606367"), axis_col = theme_foreground_color(mode, light = "#2b2b2b", dark = "#606367"),
grid = TRUE, grid = TRUE,
axis = FALSE, axis = FALSE,
axis_text = TRUE,
ticks = FALSE ticks = FALSE
) )
} }
@ -72,6 +73,8 @@ theme_inter(
\item{axis}{axis} \item{axis}{axis}
\item{axis_text}{axis text labels}
\item{ticks}{ticks} \item{ticks}{ticks}
\item{text_geom_size}{text geom size} \item{text_geom_size}{text geom size}

3
man/theme_rc.Rd

@ -28,6 +28,7 @@ theme_rc(
axis_col = theme_foreground_color(mode, light = "#2b2b2b", dark = "#606367"), axis_col = theme_foreground_color(mode, light = "#2b2b2b", dark = "#606367"),
grid = TRUE, grid = TRUE,
axis = FALSE, axis = FALSE,
axis_text = TRUE,
ticks = FALSE ticks = FALSE
) )
} }
@ -72,6 +73,8 @@ theme_rc(
\item{axis}{axis} \item{axis}{axis}
\item{axis_text}{axis text labels}
\item{ticks}{ticks} \item{ticks}{ticks}
\item{text_geom_size}{text geom size} \item{text_geom_size}{text geom size}

Loading…
Cancel
Save