Browse Source

plex-sans

tags/0.8.0
boB Rudis 7 years ago
parent
commit
b9b7d47fe4
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 12
      DESCRIPTION
  2. 4
      NAMESPACE
  3. 129
      R/modern.r
  4. 210
      R/plexsans.R
  5. 143
      R/roboto-condensed.r
  6. 2
      R/zzz.r
  7. 38
      README.Rmd
  8. 117
      README.md
  9. BIN
      README_figs/README-unnamed-chunk-10-1.png
  10. BIN
      README_figs/README-unnamed-chunk-11-1.png
  11. BIN
      README_figs/README-unnamed-chunk-12-1.png
  12. BIN
      README_figs/README-unnamed-chunk-7-1.png
  13. BIN
      README_figs/README-unnamed-chunk-8-1.png
  14. BIN
      README_figs/README-unnamed-chunk-9-1.png
  15. 99
      inst/COPYRIGHTS
  16. BIN
      inst/fonts/plex-sans/IBMPlexSans-Bold.ttf
  17. BIN
      inst/fonts/plex-sans/IBMPlexSans-Italic.ttf
  18. BIN
      inst/fonts/plex-sans/IBMPlexSans-Light.ttf
  19. BIN
      inst/fonts/plex-sans/IBMPlexSans-LightItalic.ttf
  20. BIN
      inst/fonts/plex-sans/IBMPlexSans-Medium.ttf
  21. BIN
      inst/fonts/plex-sans/IBMPlexSans-MediumItalic.ttf
  22. BIN
      inst/fonts/plex-sans/IBMPlexSans-Regular.ttf
  23. BIN
      inst/fonts/plex-sans/IBMPlexSans-Text.ttf
  24. BIN
      inst/fonts/plex-sans/IBMPlexSans-TextItalic.ttf
  25. BIN
      inst/fonts/plex-sans/IBMPlexSans-Thin.ttf
  26. BIN
      inst/fonts/plex-sans/IBMPlexSans-ThinItalic.ttf
  27. 23
      man/PlexSans.Rd
  28. 23
      man/import_plex_sans.Rd
  29. 2
      man/modern_geom_defaults.Rd
  30. 53
      man/scale_ipsum.Rd
  31. 72
      man/scale_x_percent.Rd
  32. 98
      man/theme_ipsum_ps.Rd
  33. 26
      man/theme_ipsum_rc.Rd

12
DESCRIPTION

@ -1,17 +1,19 @@
Package: hrbrthemes
Type: Package
Title: Additional Themes, Theme Components and Utilities for 'ggplot2'
Version: 0.3.3
Date: 2017-07-19
Version: 0.4.0
Date: 2017-11-15
Authors@R: c(
person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre")),
person("Google", comment = "Roboto Condensed Font", role = c("cph"))
person("Google", comment = "Roboto Condensed Font", role = c("cph")),
person("IBM", comment = "Plex Sans Font", role = c("cph"))
)
Maintainer: Bob Rudis <bob@rud.is>
Description: A compilation of extra 'ggplot2' themes, scales and utilities, including a
spell check function for plot label fields and an overall emphasis on typography.
A copy of the 'Google' font 'Roboto Condensed' <https://github.com/google/roboto/>
is also included to support one of the typography-oriented themes.
is also included and a copy of the 'IBM' 'Plex Sans' <https://github.com/IBM/type>
font is also included to support one of the typography-oriented themes.
URL: http://github.com/hrbrmstr/hrbrthemes
BugReports: https://github.com/hrbrmstr/hrbrthemes/issues
Copyright: file inst/COPYRIGHTS
@ -19,8 +21,6 @@ License: MIT + file LICENSE
Suggests:
testthat,
dplyr,
knitr,
rmarkdown,
gridExtra,
hunspell,
stringi,

4
NAMESPACE

@ -2,9 +2,12 @@
export("%>%")
export(font_an)
export(font_ps)
export(font_ps_light)
export(font_rc)
export(font_rc_light)
export(gg_check)
export(import_plex_sans)
export(import_roboto_condensed)
export(ipsum)
export(ipsum_pal)
@ -17,6 +20,7 @@ export(scale_x_percent)
export(scale_y_comma)
export(scale_y_percent)
export(theme_ipsum)
export(theme_ipsum_ps)
export(theme_ipsum_rc)
export(theme_modern_rc)
export(update_geom_font_defaults)

129
R/modern.r

@ -0,0 +1,129 @@
#' @inheritParams hrbrthemes::theme_ipsum_rc
#' @rdname theme_ipsum_rc
#' @export
theme_modern_rc <- function (base_family = "Roboto Condensed", base_size = 11.5,
plot_title_family = base_family, plot_title_size = 18, plot_title_face = "bold",
plot_title_margin = 10, subtitle_family = if (.Platform$OS.type ==
"windows") "Roboto Condensed" else "Roboto Condensed Light",
subtitle_size = 13, subtitle_face = "plain", subtitle_margin = 15,
strip_text_family = base_family, strip_text_size = 12, strip_text_face = "plain",
caption_family = if (.Platform$OS.type == "windows") "Roboto Condensed" else "Roboto Condensed Light",
caption_size = 9, caption_face = "plain", caption_margin = 10,
axis_text_size = base_size, axis_title_family = base_family,
axis_title_size = 9, axis_title_face = "plain", axis_title_just = "rt",
plot_margin = margin(30, 30, 30, 30), grid = TRUE, axis = FALSE, ticks = FALSE) {
grid_col <- axis_col <- "white"
ret <- ggplot2::theme_minimal(base_family=base_family, base_size=base_size)
ret <- ret + theme(legend.background=element_blank())
ret <- ret + theme(legend.key=element_blank())
if (inherits(grid, "character") | grid == TRUE) {
ret <- ret + theme(panel.grid=element_line(color=grid_col, size=0.2))
ret <- ret + theme(panel.grid.major=element_line(color=grid_col, size=0.2))
ret <- ret + theme(panel.grid.minor=element_line(color=grid_col, size=0.15))
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(color="white", 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(color=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(color=axis_col, size=0.15))
}
} else {
ret <- ret + theme(axis.line.x=element_line(color=axis_col, size=0.15))
ret <- ret + theme(axis.line.y=element_line(color=axis_col, size=0.15))
}
} else {
ret <- ret + theme(axis.line=element_blank())
}
if (!ticks) {
ret <- ret + theme(axis.ticks = element_blank())
ret <- ret + theme(axis.ticks.x = element_blank())
ret <- ret + theme(axis.ticks.y = element_blank())
} else {
ret <- ret + theme(axis.ticks = element_line(size=0.15))
ret <- ret + theme(axis.ticks.x = element_line(size=0.15))
ret <- ret + theme(axis.ticks.y = element_line(size=0.15))
ret <- ret + theme(axis.ticks.length = grid::unit(5, "pt"))
}
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 <- ret + theme(axis.text.x=element_text(size=axis_text_size, margin=margin(t=0)))
ret <- ret + theme(axis.text.y=element_text(size=axis_text_size, margin=margin(r=0)))
ret <- ret + theme(axis.title=element_text(size=axis_title_size, family=axis_title_family))
ret <- ret + theme(axis.title.x=element_text(hjust=xj, size=axis_title_size,
family=axis_title_family, face=axis_title_face))
ret <- ret + theme(axis.title.y=element_text(hjust=yj, size=axis_title_size,
family=axis_title_family, face=axis_title_face))
ret <- ret + theme(strip.text=element_text(hjust=0, size=strip_text_size,
face=strip_text_face, family=strip_text_family))
ret <- ret + theme(panel.spacing=grid::unit(2, "lines"))
ret <- ret + theme(plot.title=element_text(hjust=0, size=plot_title_size,
margin=margin(b=plot_title_margin),
family=plot_title_family, face=plot_title_face))
ret <- ret + theme(plot.subtitle=element_text(hjust=0, size=subtitle_size,
margin=margin(b=subtitle_margin),
family=subtitle_family, face=subtitle_face))
ret <- ret + theme(plot.caption=element_text(hjust=1, size=caption_size,
margin=margin(t=caption_margin),
family=caption_family, face=caption_face))
ret <- ret + theme(plot.margin=plot_margin)
ret <- ret +
theme(rect = element_rect(fill = "#0f0f0f", color = "#0f0f0f")) +
theme(plot.background = element_rect(fill = "#0f0f0f", color = "#0f0f0f")) +
theme(panel.background = element_rect(fill = "#0f0f0f", color = "#0f0f0f")) +
theme(rect = element_rect(fill = "#0f0f0f", color = "#0f0f0f")) +
theme(text = element_text(color = "white")) +
theme(axis.text = element_text(color = "white")) +
theme(title = element_text(color = "white")) +
theme(plot.title = element_text(color = "white")) +
theme(plot.subtitle = element_text(color = "white")) +
theme(line = element_line(color = "white")) +
theme(axis.ticks = element_line(color = "white"))
ret
}
#' Change geom defaults from black to white for the modern theme
#'
#' @export
modern_geom_defaults <- function() {
geoms <- c("abline", "area", "bar", "boxplot", "col", "crossbar",
"density", "dotplot", "errorbar", "errorbar",
"hline", "label", "line", "linerange",
"map", "path", "point", "polygon", "rect", "ribbon", "rug", "segment",
"step", "text", "tile", "violin", "vline")
for (g in geoms) {
message(g)
update_geom_defaults(g, list(colour = "white", fill = "white"))
}
}

210
R/plexsans.R

@ -0,0 +1,210 @@
#' A precise & pristine [ggplot2] theme with opinionated defaults and an emphasis on typoghraphy
#'
#' You should [import_plex_sans]() first and also install the fonts on your
#' system before trying to use this theme.
#'
#' There is an option `hrbrthemes.loadfonts` which -- if set to `TRUE` -- will
#' call `extrafont::loadfonts()` to register non-core fonts with R PDF & PostScript
#' devices. If you are running under Windows, the package calls the same function
#' to register non-core fonts with the Windows graphics device.
#'
#' @md
#' @section Why IBM Plex Sans?:
#' It's free, has tolerable kerning pairs and multiple weights. It's also different
#' "not Helvetica".
#'
#' @md
#' @param base_family,base_size base font family and size
#' @param plot_title_family,plot_title_face,plot_title_size,plot_title_margin plot tilte family, face, size and margin
#' @param subtitle_family,subtitle_face,subtitle_size plot subtitle family, face and size
#' @param subtitle_margin plot subtitle margin bottom (single numeric value)
#' @param strip_text_family,strip_text_face,strip_text_size facet label font family, face and size
#' @param caption_family,caption_face,caption_size,caption_margin plot caption family, face, size and margin
#' @param axis_title_family,axis_title_face,axis_title_size axis title font family, face and size
#' @param axis_title_just axis title font justificationk one of `[blmcrt]`
#' @param axis_text_size font size of axis text
#' @param plot_margin plot margin (specify with [ggplot2::margin])
#' @param grid_col grid color
#' @param grid panel grid (`TRUE`, `FALSE`, or a combination of `X`, `x`, `Y`, `y`)
#' @param axis_col axis color
#' @param axis add x or y axes? `TRUE`, `FALSE`, "`xy`"
#' @param ticks ticks if `TRUE` add ticks
#' @export
#' @examples \dontrun{
#' library(ggplot2)
#' library(dplyr)
#'
#' # seminal scatterplot
#' ggplot(mtcars, aes(mpg, wt)) +
#' geom_point() +
#' labs(x="Fuel effiiency (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_ipsum_rc()
#'
#' # seminal bar chart
#'
#' # note: make this font_rc on Windows
#' update_geom_font_defaults(family=font_rc_light)
#'
#' count(mpg, class) %>%
#' ggplot(aes(class, n)) +
#' geom_col() +
#' geom_text(aes(label=n), nudge_y=3) +
#' labs(x="Fuel effiiency (mpg)", y="Weight (tons)",
#' title="Seminal ggplot2 bar chart example",
#' subtitle="A plot that is only useful for demonstration purposes",
#' caption="Brought to you by the letter 'g'") +
#' theme_ipsum_rc(grid="Y") +
#' theme(axis.text.y=element_blank())
#' }
theme_ipsum_ps <- function(
base_family="IBMPlexSans", base_size = 11.5,
plot_title_family="IBMPlexSans-Bold", plot_title_size = 18,
plot_title_face="plain", plot_title_margin = 10,
subtitle_family=if (.Platform$OS.type == "windows") "IBMPlexSans" else "IBMPlexSans-Light",
subtitle_size = 13,
subtitle_face = "plain", subtitle_margin = 15,
strip_text_family = "IBMPlexSans-Medium", strip_text_size = 12,
strip_text_face = "plain",
caption_family=if (.Platform$OS.type == "windows") "IBMPlexSans" else "IBMPlexSans-Thin",
caption_size = 9,
caption_face = "plain", caption_margin = 10,
axis_text_size = 9,
axis_title_family = base_family,
axis_title_size = 9,
axis_title_face = "plain",
axis_title_just = "rt",
plot_margin = margin(30, 30, 30, 30),
grid_col = "#cccccc", grid = TRUE,
axis_col = "#cccccc", axis = FALSE, ticks = FALSE) {
ret <- ggplot2::theme_minimal(base_family=base_family, base_size=base_size)
ret <- ret + theme(legend.background=element_blank())
ret <- ret + theme(legend.key=element_blank())
if (inherits(grid, "character") | grid == TRUE) {
ret <- ret + theme(panel.grid=element_line(color=grid_col, size=0.2))
ret <- ret + theme(panel.grid.major=element_line(color=grid_col, size=0.2))
ret <- ret + theme(panel.grid.minor=element_line(color=grid_col, size=0.15))
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(color=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(color=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(color=axis_col, size=0.15))
}
} else {
ret <- ret + theme(axis.line.x=element_line(color=axis_col, size=0.15))
ret <- ret + theme(axis.line.y=element_line(color=axis_col, size=0.15))
}
} else {
ret <- ret + theme(axis.line=element_blank())
}
if (!ticks) {
ret <- ret + theme(axis.ticks = element_blank())
ret <- ret + theme(axis.ticks.x = element_blank())
ret <- ret + theme(axis.ticks.y = element_blank())
} else {
ret <- ret + theme(axis.ticks = element_line(size=0.15))
ret <- ret + theme(axis.ticks.x = element_line(size=0.15))
ret <- ret + theme(axis.ticks.y = element_line(size=0.15))
ret <- ret + theme(axis.ticks.length = grid::unit(5, "pt"))
}
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 <- ret + theme(axis.text.x=element_text(size=axis_text_size, margin=margin(t=0)))
ret <- ret + theme(axis.text.y=element_text(size=axis_text_size, margin=margin(r=0)))
ret <- ret + theme(axis.title=element_text(size=axis_title_size, family=axis_title_family))
ret <- ret + theme(axis.title.x=element_text(hjust=xj, size=axis_title_size,
family=axis_title_family, face=axis_title_face))
ret <- ret + theme(axis.title.y=element_text(hjust=yj, size=axis_title_size,
family=axis_title_family, face=axis_title_face))
ret <- ret + theme(strip.text=element_text(hjust=0, size=strip_text_size,
face=strip_text_face, family=strip_text_family))
ret <- ret + theme(panel.spacing=grid::unit(2, "lines"))
ret <- ret + theme(plot.title=element_text(hjust=0, size=plot_title_size,
margin=margin(b=plot_title_margin),
family=plot_title_family, face=plot_title_face))
ret <- ret + theme(plot.subtitle=element_text(hjust=0, size=subtitle_size,
margin=margin(b=subtitle_margin),
family=subtitle_family, face=subtitle_face))
ret <- ret + theme(plot.caption=element_text(hjust=1, size=caption_size,
margin=margin(t=caption_margin),
family=caption_family, face=caption_face))
ret <- ret + theme(plot.margin=plot_margin)
ret
}
#' Import IBM Plex Sans font for use in charts
#'
#' IBM Plex Sans is a trademark of IBM and distributed under the SIL Open Font License, Version 1.1.
#'
#' There is an option `hrbrthemes.loadfonts` which -- if set to `TRUE` -- will
#' call `extrafont::loadfonts()` to register non-core fonts with R PDF & PostScript
#' devices. If you are running under Windows, the package calls the same function
#' to register non-core fonts with the Windows graphics device.
#'
#' @md
#' @note This will take care of ensuring PDF/PostScript usage. The location of the
#' font directory is displayed after the base import is complete. It is highly
#' recommended that you install them on your system the same way you would any
#' other font you wish to use in other programs.
#' @export
import_plex_sans <- function() {
rc_font_dir <- system.file("fonts", "plex-sans", package="hrbrthemes")
suppressWarnings(suppressMessages(extrafont::font_import(rc_font_dir, prompt=FALSE)))
message(
sprintf(
"You will likely need to install these fonts on your system as well.\n\nYou can find them in [%s]",
rc_font_dir)
)
}
#' @rdname PlexSans
#' @md
#' @title PlexSans font name R variable aliases
#' @description `font_ps` == "`IBMPlexSans`"
#' @format length 1 character vector
#' @export
font_ps <- "IBMPlexSans"
#' @rdname PlexSans
#' @md
#' @note `font_ps_light` (a.k.a. "`IBMPlexSans-Light`") is not available on
#' Windows and will throw a warning if used in plots.
#' @description `font_ps_light` == "`IBMPlexSans-Light`"
#' @export
font_ps_light <- "IBMPlexSans-Light"

143
R/roboto-condensed.r

@ -15,7 +15,7 @@
#'
#' @md
#' @param base_family,base_size base font family and size
#' @param plot_title_family,plot_title_face,plot_title_size,plot_title_margin plot tilte family, face, size and margi
#' @param plot_title_family,plot_title_face,plot_title_size,plot_title_margin plot tilte family, face, size and margin
#' @param subtitle_family,subtitle_face,subtitle_size plot subtitle family, face and size
#' @param subtitle_margin plot subtitle margin bottom (single numeric value)
#' @param strip_text_family,strip_text_face,strip_text_size facet label font family, face and size
@ -163,120 +163,6 @@ theme_ipsum_rc <- function(
}
#' @inheritParams hrbrthemes::theme_ipsum_rc
#' @rdname theme_ipsum_rc
#' @export
theme_modern_rc <- function (base_family = "Roboto Condensed", base_size = 11.5,
plot_title_family = base_family, plot_title_size = 18, plot_title_face = "bold",
plot_title_margin = 10, subtitle_family = if (.Platform$OS.type ==
"windows") "Roboto Condensed" else "Roboto Condensed Light",
subtitle_size = 13, subtitle_face = "plain", subtitle_margin = 15,
strip_text_family = base_family, strip_text_size = 12, strip_text_face = "plain",
caption_family = if (.Platform$OS.type == "windows") "Roboto Condensed" else "Roboto Condensed Light",
caption_size = 9, caption_face = "plain", caption_margin = 10,
axis_text_size = base_size, axis_title_family = base_family,
axis_title_size = 9, axis_title_face = "plain", axis_title_just = "rt",
plot_margin = margin(30, 30, 30, 30), grid = TRUE, axis = FALSE, ticks = FALSE) {
grid_col <- axis_col <- "white"
ret <- ggplot2::theme_minimal(base_family=base_family, base_size=base_size)
ret <- ret + theme(legend.background=element_blank())
ret <- ret + theme(legend.key=element_blank())
if (inherits(grid, "character") | grid == TRUE) {
ret <- ret + theme(panel.grid=element_line(color=grid_col, size=0.2))
ret <- ret + theme(panel.grid.major=element_line(color=grid_col, size=0.2))
ret <- ret + theme(panel.grid.minor=element_line(color=grid_col, size=0.15))
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(color="white", 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(color=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(color=axis_col, size=0.15))
}
} else {
ret <- ret + theme(axis.line.x=element_line(color=axis_col, size=0.15))
ret <- ret + theme(axis.line.y=element_line(color=axis_col, size=0.15))
}
} else {
ret <- ret + theme(axis.line=element_blank())
}
if (!ticks) {
ret <- ret + theme(axis.ticks = element_blank())
ret <- ret + theme(axis.ticks.x = element_blank())
ret <- ret + theme(axis.ticks.y = element_blank())
} else {
ret <- ret + theme(axis.ticks = element_line(size=0.15))
ret <- ret + theme(axis.ticks.x = element_line(size=0.15))
ret <- ret + theme(axis.ticks.y = element_line(size=0.15))
ret <- ret + theme(axis.ticks.length = grid::unit(5, "pt"))
}
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 <- ret + theme(axis.text.x=element_text(size=axis_text_size, margin=margin(t=0)))
ret <- ret + theme(axis.text.y=element_text(size=axis_text_size, margin=margin(r=0)))
ret <- ret + theme(axis.title=element_text(size=axis_title_size, family=axis_title_family))
ret <- ret + theme(axis.title.x=element_text(hjust=xj, size=axis_title_size,
family=axis_title_family, face=axis_title_face))
ret <- ret + theme(axis.title.y=element_text(hjust=yj, size=axis_title_size,
family=axis_title_family, face=axis_title_face))
ret <- ret + theme(strip.text=element_text(hjust=0, size=strip_text_size,
face=strip_text_face, family=strip_text_family))
ret <- ret + theme(panel.spacing=grid::unit(2, "lines"))
ret <- ret + theme(plot.title=element_text(hjust=0, size=plot_title_size,
margin=margin(b=plot_title_margin),
family=plot_title_family, face=plot_title_face))
ret <- ret + theme(plot.subtitle=element_text(hjust=0, size=subtitle_size,
margin=margin(b=subtitle_margin),
family=subtitle_family, face=subtitle_face))
ret <- ret + theme(plot.caption=element_text(hjust=1, size=caption_size,
margin=margin(t=caption_margin),
family=caption_family, face=caption_face))
ret <- ret + theme(plot.margin=plot_margin)
ret <- ret +
theme(rect = element_rect(fill = "#0f0f0f", color = "#0f0f0f")) +
theme(plot.background = element_rect(fill = "#0f0f0f", color = "#0f0f0f")) +
theme(panel.background = element_rect(fill = "#0f0f0f", color = "#0f0f0f")) +
theme(rect = element_rect(fill = "#0f0f0f", color = "#0f0f0f")) +
theme(text = element_text(color = "white")) +
theme(axis.text = element_text(color = "white")) +
theme(title = element_text(color = "white")) +
theme(plot.title = element_text(color = "white")) +
theme(plot.subtitle = element_text(color = "white")) +
theme(line = element_line(color = "white")) +
theme(axis.ticks = element_line(color = "white"))
ret
}
#' Import Roboto Condensed font for use in charts
#'
#' Roboto Condensed is a trademark of Google.
@ -298,13 +184,14 @@ import_roboto_condensed <- function() {
suppressWarnings(suppressMessages(extrafont::font_import(rc_font_dir, prompt=FALSE)))
message(sprintf("You will likely need to install these fonts on your system as well.
You can find them in [%s]", rc_font_dir))
message(
sprintf(
"You will likely need to install these fonts on your system as well.\n\nYou can find them in [%s]",
rc_font_dir)
)
}
#' @rdname RobotoCondensed
#' @md
#' @title Roboto Condensed font name R variable aliases
@ -321,21 +208,3 @@ font_rc <- "Roboto Condensed"
#' @export
font_rc_light <- "Roboto Condensed Light"
#' Change geom defaults from black to white for the modern theme
#'
#' @export
modern_geom_defaults <- function() {
geoms <- c("abline", "area", "bar", "boxplot", "col", "crossbar",
"density", "dotplot", "errorbar", "errorbar",
"hline", "label", "line", "linerange",
"map", "path", "point", "polygon", "rect", "ribbon", "rug", "segment",
"step", "text", "tile", "violin", "vline")
for (g in geoms) {
message(g)
update_geom_defaults(g, list(colour = "white", fill = "white"))
}
}

2
R/zzz.r

@ -20,7 +20,7 @@
fnt <- extrafont::fonttable()
if (!any(grepl("Arial[ ]Narrow|Roboto[ ]Condensed", fnt$FamilyName))) {
packageStartupMessage("NOTE: Either Arial Narrow or Roboto Condensed fonts are required to use these themes.")
packageStartupMessage("NOTE: Either Arial Narrow or Roboto Condensed fonts are *required* to use these themes.")
packageStartupMessage(" Please use hrbrthemes::import_roboto_condensed() to install Roboto Condensed and")
packageStartupMessage(" if Arial Narrow is not on your system, please see http://bit.ly/arialnarrow")
} # nocov end

38
README.Rmd

@ -22,16 +22,27 @@ The core theme: `theme_ipsum` ("ipsum" is Latin for "precise") uses Arial Narrow
The following functions are implemented/objects are exported:
Core themes & scales:
- `theme_ipsum` : Arial Narrow-based theme
- `theme_ipsum_rc` : Roboto Condensed-based theme
- `gg_check`: Spell check ggplot2 plot labels
- `update_geom_font_defaults`: Update matching font defaults for text geoms (the default is — unsurprisingly — Arial Narrow)
- `scale_x_comma` / `scale_y_comma` : Comma format for axis text and `expand=c(0,0)` (you need to set limits)
- `theme_ipsum_ps` : IBM Plex Sans-based theme
- `scale_x_comma` / `scale_y_comma` : Comma format for axis text and better `expand` defaults (you need to set limits)
- `scale_x_percent` / `scale_y_percent` : Percent format for axis text and `expand=c(0,0)` (you need to set limits)
- `scale_color_ipsum` / `scale_fill_ipsum` / `ipsum_pal` : A muted discrete color palette with 9 colors
Utilities:
- `gg_check`: Spell check ggplot2 plot labels
- `update_geom_font_defaults`: Update matching font defaults for text geoms (the default is — unsurprisingly — Arial Narrow)
The following global variables are now in your namespace:
- `font_an`: a short global alias for "`Arial Narrow`"
- `font_rc`: a short global alias for "`Roboto Condensed`"
- `font_rc_light`: a short global alias for "`Roboto Condensed Light`"
- `font_ps`: a short global alias for "`IBMPlexSans`"
- `font_ps_light`: a short global alias for "`IBMPlexSans-Light`"
### Installation
@ -78,6 +89,27 @@ ggplot(mtcars, aes(mpg, wt)) +
theme_ipsum_rc()
```
### IBM Plex Sans
```{r fig.width=10, fig.height=7, fig.retina=2}
ggplot(mpg, aes(displ, hwy)) +
geom_jitter(aes(color=class, fill=class), size=3, shape=21, alpha=1/2) +
scale_x_continuous(expand=c(0,0), limits=c(1, 8), breaks=1:8) +
scale_y_continuous(expand=c(0,0), limits=c(10, 50)) +
scale_color_ipsum() +
scale_fill_ipsum() +
facet_wrap(~class, scales="free") +
labs(
title="IBM Plex Sans Test",
subtitle="This is a subtitle to see the how it looks in IBM Plex Sans",
caption="Source: hrbrthemes & IBM"
) +
theme_ipsum_ps(grid="XY", axis="xy") +
theme(axis.text.x=element_text(hjust=c(0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1))) +
theme(axis.text.y=element_text(vjust=c(0, 0.5, 0.5, 0.5, 1))) +
theme(legend.position="none")
```
### Scales (Color/Fill)
```{r fig.retina=2}

117
README.md

@ -1,27 +1,58 @@
`hrbrthemes` : Additional Themes and Theme Components for 'ggplot2'
-------------------------------------------------------------------
## `hrbrthemes` : Additional Themes and Theme Components for ‘ggplot2’
[![Project Status: Active - The project has reached a stable, usable
state and is being actively
developed.](http://www.repostatus.org/badges/0.1.0/active.svg)](http://www.repostatus.org/#active)
[![codecov](https://codecov.io/gh/hrbrmstr/hrbrthemes/branch/master/graph/badge.svg)](https://codecov.io/gh/hrbrmstr/hrbrthemes)
[![Travis-CI Build
Status](https://travis-ci.org/hrbrmstr/hrbrthemes.svg?branch=master)](https://travis-ci.org/hrbrmstr/hrbrthemes)
[![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/hrbrthemes)](https://cran.r-project.org/package=hrbrthemes)
![downloads](http://cranlogs.r-pkg.org/badges/grand-total/hrbrthemes)
<!-- [![keybase verified](https://img.shields.io/badge/keybase-verified-brightgreen.svg)](https://gist.github.com/hrbrmstr/be2f2c14fd78cac24697) -->
-----
This is a very focused package that provides typography-centric themes
and theme components for ggplot2. It’s a an extract/riff of
[`hrbrmisc`](http://github.com/hrbrmstr/hrbrmisc) created by request.
The core theme: `theme_ipsum` (“ipsum” is Latin for “precise”) uses
Arial Narrow which should be installed on practically any modern system,
so it’s “free”-ish. This font is condensed, has solid default kerning
pairs and geometric numbers. That’s what I consider the “font trifecta”
must-have for charts. An additional quality for fonts for charts is that
they have a diversity of weights. Arial Narrow (the one on most systems,
anyway) does not have said diversity but this quality is not (IMO) a
“must have”.
[![Project Status: Active - The project has reached a stable, usable state and is being actively developed.](http://www.repostatus.org/badges/0.1.0/active.svg)](http://www.repostatus.org/#active) [![codecov](https://codecov.io/gh/hrbrmstr/hrbrthemes/branch/master/graph/badge.svg)](https://codecov.io/gh/hrbrmstr/hrbrthemes) [![Travis-CI Build Status](https://travis-ci.org/hrbrmstr/hrbrthemes.svg?branch=master)](https://travis-ci.org/hrbrmstr/hrbrthemes) [![CRAN\_Status\_Badge](http://www.r-pkg.org/badges/version/hrbrthemes)](https://cran.r-project.org/package=hrbrthemes) ![downloads](http://cranlogs.r-pkg.org/badges/grand-total/hrbrthemes) <!-- [![keybase verified](https://img.shields.io/badge/keybase-verified-brightgreen.svg)](https://gist.github.com/hrbrmstr/be2f2c14fd78cac24697) -->
The following functions are implemented/objects are exported:
------------------------------------------------------------------------
Core themes & scales:
This is a very focused package that provides typography-centric themes and theme components for ggplot2. It's a an extract/riff of [`hrbrmisc`](http://github.com/hrbrmstr/hrbrmisc) created by request.
- `theme_ipsum` : Arial Narrow-based theme
- `theme_ipsum_rc` : Roboto Condensed-based theme
- `theme_ipsum_ps` : IBM Plex Sans-based theme
- `scale_x_comma` / `scale_y_comma` : Comma format for axis text and
better `expand` defaults (you need to set limits)
- `scale_x_percent` / `scale_y_percent` : Percent format for axis text
and `expand=c(0,0)` (you need to set limits)
- `scale_color_ipsum` / `scale_fill_ipsum` / `ipsum_pal` : A muted
discrete color palette with 9 colors
The core theme: `theme_ipsum` ("ipsum" is Latin for "precise") uses Arial Narrow which should be installed on practically any modern system, so it's "free"-ish. This font is condensed, has solid default kerning pairs and geometric numbers. That's what I consider the "font trifecta" must-have for charts. An additional quality for fonts for charts is that they have a diversity of weights. Arial Narrow (the one on most systems, anyway) does not have said diversity but this quality is not (IMO) a "must have".
Utilities:
The following functions are implemented/objects are exported:
- `gg_check`: Spell check ggplot2 plot labels
- `update_geom_font_defaults`: Update matching font defaults for text
geoms (the default is — unsurprisingly — Arial Narrow)
The following global variables are now in your namespace:
- `theme_ipsum` : Arial Narrow-based theme
- `theme_ipsum_rc` : Roboto Condensed-based theme
- `gg_check`: Spell check ggplot2 plot labels
- `update_geom_font_defaults`: Update matching font defaults for text geoms (the default is — unsurprisingly — Arial Narrow)
- `scale_x_comma` / `scale_y_comma` : Comma format for axis text and `expand=c(0,0)` (you need to set limits)
- `scale_x_percent` / `scale_y_percent` : Percent format for axis text and `expand=c(0,0)` (you need to set limits)
- `scale_color_ipsum` / `scale_fill_ipsum` / `ipsum_pal` : A muted discrete color palette with 9 colors
- `font_an`: a short global alias for "`Arial Narrow`"
- `font_rc`: a short global alias for "`Roboto Condensed`"
- `font_rc_light`: a short global alias for "`Roboto Condensed Light`"
- `font_an`: a short global alias for “`Arial Narrow`”
- `font_rc`: a short global alias for “`Roboto Condensed`”
- `font_rc_light`: a short global alias for “`Roboto Condensed Light`”
- `font_ps`: a short global alias for “`IBMPlexSans`”
- `font_ps_light`: a short global alias for “`IBMPlexSans-Light`”
### Installation
@ -38,7 +69,7 @@ library(tidyverse)
# current verison
packageVersion("hrbrthemes")
## [1] '0.3.2'
## [1] '0.4.0'
```
### Base theme (Arial Narrow)
@ -69,6 +100,29 @@ ggplot(mtcars, aes(mpg, wt)) +
<img src="README_figs/README-unnamed-chunk-6-1.png" width="672" />
### IBM Plex Sans
``` r
ggplot(mpg, aes(displ, hwy)) +
geom_jitter(aes(color=class, fill=class), size=3, shape=21, alpha=1/2) +
scale_x_continuous(expand=c(0,0), limits=c(1, 8), breaks=1:8) +
scale_y_continuous(expand=c(0,0), limits=c(10, 50)) +
scale_color_ipsum() +
scale_fill_ipsum() +
facet_wrap(~class, scales="free") +
labs(
title="IBM Plex Sans Test",
subtitle="This is a subtitle to see the how it looks in IBM Plex Sans",
caption="Source: hrbrthemes & IBM"
) +
theme_ipsum_ps(grid="XY", axis="xy") +
theme(axis.text.x=element_text(hjust=c(0, 0.5, 0.5, 0.5, 0.5, 0.5, 0.5, 1))) +
theme(axis.text.y=element_text(vjust=c(0, 0.5, 0.5, 0.5, 1))) +
theme(legend.position="none")
```
<img src="README_figs/README-unnamed-chunk-7-1.png" width="960" />
### Scales (Color/Fill)
``` r
@ -82,7 +136,7 @@ ggplot(mtcars, aes(mpg, wt)) +
theme_ipsum_rc()
```
<img src="README_figs/README-unnamed-chunk-7-1.png" width="672" />
<img src="README_figs/README-unnamed-chunk-8-1.png" width="672" />
### Scales (Axis)
@ -99,7 +153,7 @@ count(mpg, class) %>%
theme_ipsum(grid="Y")
```
<img src="README_figs/README-unnamed-chunk-8-1.png" width="672" />
<img src="README_figs/README-unnamed-chunk-9-1.png" width="672" />
``` r
ggplot(uspopage, aes(x=Year, y=Thousands, fill=AgeGroup)) +
@ -115,7 +169,7 @@ ggplot(uspopage, aes(x=Year, y=Thousands, fill=AgeGroup)) +
theme(legend.position="bottom")
```
<img src="README_figs/README-unnamed-chunk-9-1.png" width="672" />
<img src="README_figs/README-unnamed-chunk-10-1.png" width="672" />
``` r
update_geom_font_defaults(font_rc_light)
@ -136,7 +190,7 @@ count(mpg, class) %>%
theme_ipsum_rc(grid="X")
```
<img src="README_figs/README-unnamed-chunk-10-1.png" width="672" />
<img src="README_figs/README-unnamed-chunk-11-1.png" width="672" />
### Spellcheck ggplot2 labels
@ -157,7 +211,7 @@ gg_check(gg)
## Possible misspelled words in [caption]: (captien)
```
<img src="README_figs/README-unnamed-chunk-11-1.png" width="672" />
<img src="README_figs/README-unnamed-chunk-12-1.png" width="672" />
### Test Results
@ -165,17 +219,26 @@ gg_check(gg)
library(hrbrthemes)
date()
## [1] "Thu Jun 22 08:45:46 2017"
## [1] "Wed Nov 15 08:34:26 2017"
devtools::test()
## basic functionality: ..........
## themes:
## .
## .
## S
## S
##
## Skipped ----------------------------------------------------------------------------------------------------------------
## 1. themes are correct (@test-themes.R#10) - Failed doppelganger but vdiffr can't check its FreeType version.
## Please revalidate cases with a more recent vdiffr
##
## 2. themes are correct (@test-themes.R#11) - Failed doppelganger but vdiffr can't check its FreeType version.
## Please revalidate cases with a more recent vdiffr
##
## DONE ===================================================================================================================
```
### Code of Conduct
Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.
Please note that this project is released with a [Contributor Code of
Conduct](CONDUCT.md). By participating in this project you agree to
abide by its terms.

BIN
README_figs/README-unnamed-chunk-10-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 132 KiB

BIN
README_figs/README-unnamed-chunk-11-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 94 KiB

BIN
README_figs/README-unnamed-chunk-12-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

BIN
README_figs/README-unnamed-chunk-7-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 215 KiB

BIN
README_figs/README-unnamed-chunk-8-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 85 KiB

BIN
README_figs/README-unnamed-chunk-9-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 132 KiB

After

Width:  |  Height:  |  Size: 82 KiB

99
inst/COPYRIGHTS

@ -1,5 +1,104 @@
All R source code files are released under the MIT license.
-----------------------------
IBM Plex Sans font has the following license/copyright:
Copyright © 2017 IBM Corp. with Reserved Font Name "Plex"
This Font Software is licensed under the SIL Open Font License, Version 1.1.
This license is copied below, and is also available with a FAQ at:
http://scripts.sil.org/OFL
-----------------------------------------------------------
SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
-----------------------------------------------------------
PREAMBLE
The goals of the Open Font License (OFL) are to stimulate worldwide
development of collaborative font projects, to support the font creation
efforts of academic and linguistic communities, and to provide a free and
open framework in which fonts may be shared and improved in partnership
with others.
The OFL allows the licensed fonts to be used, studied, modified and
redistributed freely as long as they are not sold by themselves. The
fonts, including any derivative works, can be bundled, embedded,
redistributed and/or sold with any software provided that any reserved
names are not used by derivative works. The fonts and derivatives,
however, cannot be released under any other type of license. The
requirement for fonts to remain under this license does not apply
to any document created using the fonts or their derivatives.
DEFINITIONS
"Font Software" refers to the set of files released by the Copyright
Holder(s) under this license and clearly marked as such. This may
include source files, build scripts and documentation.
"Reserved Font Name" refers to any names specified as such after the
copyright statement(s).
"Original Version" refers to the collection of Font Software components as
distributed by the Copyright Holder(s).
"Modified Version" refers to any derivative made by adding to, deleting,
or substituting -- in part or in whole -- any of the components of the
Original Version, by changing formats or by porting the Font Software to a
new environment.
"Author" refers to any designer, engineer, programmer, technical
writer or other person who contributed to the Font Software.
PERMISSION & CONDITIONS
Permission is hereby granted, free of charge, to any person obtaining
a copy of the Font Software, to use, study, copy, merge, embed, modify,
redistribute, and sell modified and unmodified copies of the Font
Software, subject to the following conditions:
1) Neither the Font Software nor any of its individual components,
in Original or Modified Versions, may be sold by itself.
2) Original or Modified Versions of the Font Software may be bundled,
redistributed and/or sold with any software, provided that each copy
contains the above copyright notice and this license. These can be
included either as stand-alone text files, human-readable headers or
in the appropriate machine-readable metadata fields within text or
binary files as long as those fields can be easily viewed by the user.
3) No Modified Version of the Font Software may use the Reserved Font
Name(s) unless explicit written permission is granted by the corresponding
Copyright Holder. This restriction only applies to the primary font name as
presented to the users.
4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
Software shall not be used to promote, endorse or advertise any
Modified Version, except to acknowledge the contribution(s) of the
Copyright Holder(s) and the Author(s) or with their explicit written
permission.
5) The Font Software, modified or unmodified, in part or in whole,
must be distributed entirely under this license, and must not be
distributed under any other license. The requirement for fonts to
remain under this license does not apply to any document created
using the Font Software.
TERMINATION
This license becomes null and void if any of the above conditions are
not met.
DISCLAIMER
THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
OTHER DEALINGS IN THE FONT SOFTWARE.
-----------------------------
The Google Roboto Condensed & Slab fonts <https://github.com/google/roboto/> have
the folllowing copyright:

BIN
inst/fonts/plex-sans/IBMPlexSans-Bold.ttf

Binary file not shown.

BIN
inst/fonts/plex-sans/IBMPlexSans-Italic.ttf

Binary file not shown.

BIN
inst/fonts/plex-sans/IBMPlexSans-Light.ttf

Binary file not shown.

BIN
inst/fonts/plex-sans/IBMPlexSans-LightItalic.ttf

Binary file not shown.

BIN
inst/fonts/plex-sans/IBMPlexSans-Medium.ttf

Binary file not shown.

BIN
inst/fonts/plex-sans/IBMPlexSans-MediumItalic.ttf

Binary file not shown.

BIN
inst/fonts/plex-sans/IBMPlexSans-Regular.ttf

Binary file not shown.

BIN
inst/fonts/plex-sans/IBMPlexSans-Text.ttf

Binary file not shown.

BIN
inst/fonts/plex-sans/IBMPlexSans-TextItalic.ttf

Binary file not shown.

BIN
inst/fonts/plex-sans/IBMPlexSans-Thin.ttf

Binary file not shown.

BIN
inst/fonts/plex-sans/IBMPlexSans-ThinItalic.ttf

Binary file not shown.

23
man/PlexSans.Rd

@ -0,0 +1,23 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plexsans.R
\docType{data}
\name{font_ps}
\alias{font_ps}
\alias{font_ps_light}
\title{PlexSans font name R variable aliases}
\format{length 1 character vector}
\usage{
font_ps
font_ps_light
}
\description{
\code{font_ps} == "\code{IBMPlexSans}"
\code{font_ps_light} == "\code{IBMPlexSans-Light}"
}
\note{
\code{font_ps_light} (a.k.a. "\code{IBMPlexSans-Light}") is not available on
Windows and will throw a warning if used in plots.
}
\keyword{datasets}

23
man/import_plex_sans.Rd

@ -0,0 +1,23 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plexsans.R
\name{import_plex_sans}
\alias{import_plex_sans}
\title{Import IBM Plex Sans font for use in charts}
\usage{
import_plex_sans()
}
\description{
IBM Plex Sans is a trademark of IBM and distributed under the SIL Open Font License, Version 1.1.
}
\details{
There is an option \code{hrbrthemes.loadfonts} which -- if set to \code{TRUE} -- will
call \code{extrafont::loadfonts()} to register non-core fonts with R PDF & PostScript
devices. If you are running under Windows, the package calls the same function
to register non-core fonts with the Windows graphics device.
}
\note{
This will take care of ensuring PDF/PostScript usage. The location of the
font directory is displayed after the base import is complete. It is highly
recommended that you install them on your system the same way you would any
other font you wish to use in other programs.
}

2
man/modern_geom_defaults.Rd

@ -1,5 +1,5 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/roboto-condensed.r
% Please edit documentation in R/modern.r
\name{modern_geom_defaults}
\alias{modern_geom_defaults}
\title{Change geom defaults from black to white for the modern theme}

53
man/scale_ipsum.Rd

@ -13,8 +13,57 @@ scale_color_ipsum(...)
scale_fill_ipsum(...)
}
\arguments{
\item{...}{Other arguments passed on to \code{\link{discrete_scale}}
to control name, limits, breaks, labels and so forth.}
\item{...}{Arguments passed on to \code{discrete_scale}
\describe{
\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 character vector of breaks
\item A function that takes the limits as input and returns breaks
as output
}}
\item{limits}{A character vector that defines possible values of the scale
and their order.}
\item{drop}{Should unused factor levels be omitted from the scale?
The default, \code{TRUE}, uses the levels that appear in the data;
\code{FALSE} uses all the levels in the factor.}
\item{na.translate}{Unlike continuous scales, discrete scales can easily show
missing values, and do so by default. If you want to remove missing values
from a discrete scale, specify \code{na.translate = FALSE}.}
\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{aesthetics}{The names of the aesthetics that this scale works with}
\item{scale_name}{The name of the scale}
\item{palette}{A palette function that when called with a single integer
argument (the number of levels in the scale) returns the values that
they should take}
\item{name}{The name of the scale. Used as axis or legend title. If
\code{NULL}, the default, the name of the scale is taken from the first
mapping used for that aesthetic.}
\item{labels}{One of:
\itemize{
\item \code{NULL} for no labels
\item \code{waiver()} for the default labels computed by the
transformation object
\item A character vector giving labels (must be same length as \code{breaks})
\item A function that takes the breaks as input and returns labels
as output
}}
\item{expand}{Vector of range expansion constants used to add some
padding around the data, to ensure that they are placed some distance
away from the axes. Use the convenience function \code{\link[=expand_scale]{expand_scale()}}
to generate the values for the \code{expand} argument. The defaults are to
expand the scale by 5\% on each side for continuous variables, and by
0.6 units on each side for discrete variables.}
\item{guide}{A function used to create a guide or its name. See
\code{\link[=guides]{guides()}} for more info.}
\item{position}{The position of the axis. "left" or "right" for vertical
scales, "top" or "bottom" for horizontal scales}
\item{super}{The super class to use for the constructed scale}
}}
}
\description{
See \url{ipsum_pal}.

72
man/scale_x_percent.Rd

@ -32,40 +32,44 @@ scale_y_comma(name = waiver(), breaks = waiver(), minor_breaks = waiver(),
\code{NULL}, the default, the name of the scale is taken from the first
mapping used for that aesthetic.}
\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{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{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{labels}{One of: \itemize{
\item \code{NULL} for no labels
\item \code{waiver()} for the default labels computed by the
transformation object
\item A character vector giving labels (must be same length as \code{breaks})
\item A function that takes the breaks as input and returns labels
as output
\item{labels}{One of:
\itemize{
\item \code{NULL} for no labels
\item \code{waiver()} for the default labels computed by the
transformation object
\item A character vector giving labels (must be same length as \code{breaks})
\item A function that takes the breaks as input and returns labels
as output
}}
\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}{A numeric vector of length two giving multiplicative and
additive expansion constants. These constants ensure that the data is
placed some distance away from the axes. The defaults are
\code{c(0.05, 0)} for continuous variables, and \code{c(0, 0.6)} for
discrete variables.}
\item{expand}{Vector of range expansion constants used to add some
padding around the data, to ensure that they are placed some distance
away from the axes. Use the convenience function \code{\link[=expand_scale]{expand_scale()}}
to generate the values for the \code{expand} argument. The defaults are to
expand the scale by 5\% on each side for continuous variables, and by
0.6 units on each side for discrete variables.}
\item{oob}{Function that handles limits outside of the scale limits
(out of bounds). The default replaces out of bounds values with NA.}
@ -73,20 +77,20 @@ discrete variables.}
\item{na.value}{Missing values will be replaced with this value.}
\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".
object itself. Built-in transformations include "asn", "atanh",
"boxcox", "exp", "identity", "log", "log10", "log1p", "log2",
"logit", "probability", "probit", "reciprocal", "reverse" and "sqrt".
A transformation object bundles together a transform, it's inverse,
and methods for generating breaks and labels. Transformation objects
are defined in the scales package, and are called \code{name_trans}, e.g.
\code{\link[scales]{boxcox_trans}}. You can create your own
transformation with \code{\link[scales]{trans_new}}.}
A transformation object bundles together a transform, it's inverse,
and methods for generating breaks and labels. Transformation objects
are defined in the scales package, and are called \code{name_trans}, e.g.
\code{\link[scales:boxcox_trans]{scales::boxcox_trans()}}. You can create your own
transformation with \code{\link[scales:trans_new]{scales::trans_new()}}.}
\item{position}{The position of the axis. "left" or "right" for vertical
scales, "top" or "bottom" for horizontal scales}
\item{sec.axis}{specifify a secondary axis}
\item{sec.axis}{specify a secondary axis}
}
\description{
The \code{_comma} ones set comma format for axis text and \code{expand=c(0,0)} (you need to set limits).

98
man/theme_ipsum_ps.Rd

@ -0,0 +1,98 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plexsans.R
\name{theme_ipsum_ps}
\alias{theme_ipsum_ps}
\title{A precise & pristine \link{ggplot2} theme with opinionated defaults and an emphasis on typoghraphy}
\usage{
theme_ipsum_ps(base_family = "IBMPlexSans", base_size = 11.5,
plot_title_family = "IBMPlexSans-Bold", plot_title_size = 18,
plot_title_face = "plain", plot_title_margin = 10, subtitle_family = if
(.Platform$OS.type == "windows") "IBMPlexSans" else "IBMPlexSans-Light",
subtitle_size = 13, subtitle_face = "plain", subtitle_margin = 15,
strip_text_family = "IBMPlexSans-Medium", strip_text_size = 12,
strip_text_face = "plain", caption_family = if (.Platform$OS.type ==
"windows") "IBMPlexSans" else "IBMPlexSans-Thin", caption_size = 9,
caption_face = "plain", caption_margin = 10, axis_text_size = 9,
axis_title_family = base_family, axis_title_size = 9,
axis_title_face = "plain", axis_title_just = "rt",
plot_margin = margin(30, 30, 30, 30), grid_col = "#cccccc", grid = TRUE,
axis_col = "#cccccc", axis = FALSE, ticks = FALSE)
}
\arguments{
\item{base_family, base_size}{base font family and size}
\item{plot_title_family, plot_title_face, plot_title_size, plot_title_margin}{plot tilte family, face, size and margin}
\item{subtitle_family, subtitle_face, subtitle_size}{plot subtitle family, face and size}
\item{subtitle_margin}{plot subtitle margin bottom (single numeric value)}
\item{strip_text_family, strip_text_face, strip_text_size}{facet label font family, face and size}
\item{caption_family, caption_face, caption_size, caption_margin}{plot caption family, face, size and margin}
\item{axis_text_size}{font size of axis text}
\item{axis_title_family, axis_title_face, axis_title_size}{axis title font family, face and size}
\item{axis_title_just}{axis title font justificationk one of \code{[blmcrt]}}
\item{plot_margin}{plot margin (specify with \link[ggplot2:margin]{ggplot2::margin})}
\item{grid_col}{grid color}
\item{grid}{panel grid (\code{TRUE}, \code{FALSE}, or a combination of \code{X}, \code{x}, \code{Y}, \code{y})}
\item{axis_col}{axis color}
\item{axis}{add x or y axes? \code{TRUE}, \code{FALSE}, "\code{xy}"}
\item{ticks}{ticks if \code{TRUE} add ticks}
}
\description{
You should \url{import_plex_sans} first and also install the fonts on your
system before trying to use this theme.
}
\details{
There is an option \code{hrbrthemes.loadfonts} which -- if set to \code{TRUE} -- will
call \code{extrafont::loadfonts()} to register non-core fonts with R PDF & PostScript
devices. If you are running under Windows, the package calls the same function
to register non-core fonts with the Windows graphics device.
}
\section{Why IBM Plex Sans?}{
It's free, has tolerable kerning pairs and multiple weights. It's also different
"not Helvetica".
}
\examples{
\dontrun{
library(ggplot2)
library(dplyr)
# seminal scatterplot
ggplot(mtcars, aes(mpg, wt)) +
geom_point() +
labs(x="Fuel effiiency (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_ipsum_rc()
# seminal bar chart
# note: make this font_rc on Windows
update_geom_font_defaults(family=font_rc_light)
count(mpg, class) \%>\%
ggplot(aes(class, n)) +
geom_col() +
geom_text(aes(label=n), nudge_y=3) +
labs(x="Fuel effiiency (mpg)", y="Weight (tons)",
title="Seminal ggplot2 bar chart example",
subtitle="A plot that is only useful for demonstration purposes",
caption="Brought to you by the letter 'g'") +
theme_ipsum_rc(grid="Y") +
theme(axis.text.y=element_blank())
}
}

26
man/theme_ipsum_rc.Rd

@ -1,11 +1,11 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/roboto-condensed.r
\name{theme_ipsum_rc}
\alias{theme_ipsum_rc}
% Please edit documentation in R/modern.r, R/roboto-condensed.r
\name{theme_modern_rc}
\alias{theme_modern_rc}
\alias{theme_ipsum_rc}
\title{A precise & pristine \link{ggplot2} theme with opinionated defaults and an emphasis on typoghraphy}
\usage{
theme_ipsum_rc(base_family = "Roboto Condensed", base_size = 11.5,
theme_modern_rc(base_family = "Roboto Condensed", base_size = 11.5,
plot_title_family = base_family, plot_title_size = 18,
plot_title_face = "bold", plot_title_margin = 10, subtitle_family = if
(.Platform$OS.type == "windows") "Roboto Condensed" else
@ -17,10 +17,10 @@ theme_ipsum_rc(base_family = "Roboto Condensed", base_size = 11.5,
caption_margin = 10, axis_text_size = base_size,
axis_title_family = base_family, axis_title_size = 9,
axis_title_face = "plain", axis_title_just = "rt",
plot_margin = margin(30, 30, 30, 30), grid_col = "#cccccc", grid = TRUE,
axis_col = "#cccccc", axis = FALSE, ticks = FALSE)
plot_margin = margin(30, 30, 30, 30), grid = TRUE, axis = FALSE,
ticks = FALSE)
theme_modern_rc(base_family = "Roboto Condensed", base_size = 11.5,
theme_ipsum_rc(base_family = "Roboto Condensed", base_size = 11.5,
plot_title_family = base_family, plot_title_size = 18,
plot_title_face = "bold", plot_title_margin = 10, subtitle_family = if
(.Platform$OS.type == "windows") "Roboto Condensed" else
@ -32,8 +32,8 @@ theme_modern_rc(base_family = "Roboto Condensed", base_size = 11.5,
caption_margin = 10, axis_text_size = base_size,
axis_title_family = base_family, axis_title_size = 9,
axis_title_face = "plain", axis_title_just = "rt",
plot_margin = margin(30, 30, 30, 30), grid = TRUE, axis = FALSE,
ticks = FALSE)
plot_margin = margin(30, 30, 30, 30), grid_col = "#cccccc", grid = TRUE,
axis_col = "#cccccc", axis = FALSE, ticks = FALSE)
}
\arguments{
\item{base_family, base_size}{base font family and size}
@ -56,15 +56,15 @@ theme_modern_rc(base_family = "Roboto Condensed", base_size = 11.5,
\item{plot_margin}{plot margin (specify with \link[ggplot2:margin]{ggplot2::margin})}
\item{grid_col}{grid color}
\item{grid}{panel grid (\code{TRUE}, \code{FALSE}, or a combination of \code{X}, \code{x}, \code{Y}, \code{y})}
\item{axis_col}{axis color}
\item{axis}{add x or y axes? \code{TRUE}, \code{FALSE}, "\code{xy}"}
\item{ticks}{ticks if \code{TRUE} add ticks}
\item{grid_col}{grid color}
\item{axis_col}{axis color}
}
\description{
You should \url{import_roboto_condensed} first and also install the fonts on your

Loading…
Cancel
Save