Compare commits

...

No commits in common. 'master' and '0.7.0' have entirely different histories.

  1. 8
      .Rbuildignore
  2. 3
      .github/FUNDING.yml
  3. 4
      .gitignore
  4. 28
      .travis.yml
  5. 4
      CRAN-RELEASE
  6. 17
      DESCRIPTION
  7. 26
      NAMESPACE
  8. 19
      NEWS.md
  9. 2
      R/color.r
  10. 245
      R/econ-sans.R
  11. 3
      R/ft.R
  12. 209
      R/goldmansans.R
  13. 2
      R/hrbrthemes-package.R
  14. 259
      R/inter.R
  15. 1
      R/ipsum-pdf.R
  16. 1
      R/modern.r
  17. 20
      R/plexsans.R
  18. 228
      R/public-sans.R
  19. 143
      R/roboto-condensed.r
  20. 347
      R/scales.r
  21. 382
      R/theme-ipsum.r
  22. 179
      R/tinyhand.R
  23. 21
      R/titillium-web.R
  24. 43
      R/zzz.r
  25. 96
      README.Rmd
  26. 145
      README.md
  27. BIN
      README_figs/README-ft-1.png
  28. BIN
      README_figs/README-unnamed-chunk-10-1.png
  29. BIN
      README_figs/README-unnamed-chunk-11-1.png
  30. BIN
      README_figs/README-unnamed-chunk-12-1.png
  31. BIN
      README_figs/README-unnamed-chunk-13-1.png
  32. BIN
      README_figs/README-unnamed-chunk-5-1.png
  33. BIN
      README_figs/README-unnamed-chunk-6-1.png
  34. BIN
      README_figs/README-unnamed-chunk-7-1.png
  35. BIN
      README_figs/README-unnamed-chunk-8-1.png
  36. BIN
      README_figs/README-unnamed-chunk-9-1.png
  37. BIN
      README_files/figure-gfm/ft-1.png
  38. BIN
      README_files/figure-gfm/unnamed-chunk-10-1.png
  39. BIN
      README_files/figure-gfm/unnamed-chunk-2-1.png
  40. BIN
      README_files/figure-gfm/unnamed-chunk-3-1.png
  41. BIN
      README_files/figure-gfm/unnamed-chunk-4-1.png
  42. BIN
      README_files/figure-gfm/unnamed-chunk-5-1.png
  43. BIN
      README_files/figure-gfm/unnamed-chunk-6-1.png
  44. BIN
      README_files/figure-gfm/unnamed-chunk-7-1.png
  45. BIN
      README_files/figure-gfm/unnamed-chunk-8-1.png
  46. BIN
      README_files/figure-gfm/unnamed-chunk-9-1.png
  47. BIN
      README_files/figure-markdown_github/unnamed-chunk-10-1.png
  48. BIN
      README_files/figure-markdown_github/unnamed-chunk-10-2.png
  49. BIN
      README_files/figure-markdown_github/unnamed-chunk-4-1.png
  50. BIN
      README_files/figure-markdown_github/unnamed-chunk-5-1.png
  51. BIN
      README_files/figure-markdown_github/unnamed-chunk-6-1.png
  52. BIN
      README_files/figure-markdown_github/unnamed-chunk-7-1.png
  53. BIN
      README_files/figure-markdown_github/unnamed-chunk-8-1.png
  54. BIN
      README_files/figure-markdown_github/unnamed-chunk-9-1.png
  55. 20
      cran-comments.md
  56. 2
      docs/CONDUCT.html
  57. 2
      docs/LICENSE-text.html
  58. 2
      docs/articles/index.html
  59. 4
      docs/articles/why_hrbrthemes.html
  60. 2
      docs/authors.html
  61. 17
      docs/index.html
  62. 2
      docs/news/index.html
  63. 2
      docs/pkgdown.css
  64. 9
      docs/pkgdown.js
  65. 2
      docs/pkgdown.yml
  66. 2
      docs/reference/ArialNarrow.html
  67. 2
      docs/reference/PlexSans.html
  68. 2
      docs/reference/RobotoCondensed.html
  69. 2
      docs/reference/TitilliumWeb.html
  70. 2
      docs/reference/flush_ticks.html
  71. 2
      docs/reference/ft_cols.html
  72. 2
      docs/reference/ft_geom_defaults.html
  73. 2
      docs/reference/ft_pal.html
  74. 2
      docs/reference/gg_check.html
  75. 2
      docs/reference/hrbrthemes-exports.html
  76. 2
      docs/reference/hrbrthemes.html
  77. 2
      docs/reference/import_plex_sans.html
  78. 2
      docs/reference/import_roboto_condensed.html
  79. 2
      docs/reference/import_titillium_web.html
  80. 2
      docs/reference/index.html
  81. 4
      docs/reference/ipsum.html
  82. 2
      docs/reference/ipsum_pal.html
  83. 2
      docs/reference/ipsum_pdf.html
  84. 2
      docs/reference/modern_geom_defaults.html
  85. 2
      docs/reference/scale_ft.html
  86. 2
      docs/reference/scale_ipsum.html
  87. 2
      docs/reference/scale_x_percent.html
  88. 2
      docs/reference/theme_ipsum.html
  89. 2
      docs/reference/theme_ipsum_ps.html
  90. 2
      docs/reference/theme_ipsum_rc.html
  91. 2
      docs/reference/theme_ipsum_tw.html
  92. 2
      docs/reference/update_geom_font_defaults.html
  93. 110
      inst/COPYRIGHTS
  94. BIN
      inst/fonts/econ-sans/econsans-condensed-primary-subset-bd-it.ttf
  95. BIN
      inst/fonts/econ-sans/econsans-condensed-primary-subset-bd.ttf
  96. BIN
      inst/fonts/econ-sans/econsans-condensed-primary-subset-it.ttf
  97. BIN
      inst/fonts/econ-sans/econsans-condensed-primary-subset-li-it.ttf
  98. BIN
      inst/fonts/econ-sans/econsans-condensed-primary-subset-li.ttf
  99. BIN
      inst/fonts/econ-sans/econsans-condensed-primary-subset-md-it.ttf
  100. BIN
      inst/fonts/econ-sans/econsans-condensed-primary-subset-md.ttf

8
.Rbuildignore

@ -1,16 +1,10 @@
^\.github
^CRAN-RELEASE$
^.*\.Rproj$
^\.Rproj\.user$
^\.travis\.yml$
^README\.Rmd$
^README\.md$
^README\.html$
^README_files$
^README.*$
^NOTES.*$
^notes.*$
^CONDUCT\.md$
^cran-comments\.md$
^docs$
^doc$
^Meta$

3
.github/FUNDING.yml

@ -1,3 +0,0 @@
# These are supported funding model platforms
patreon: hrbrmstr

4
.gitignore

@ -7,6 +7,4 @@ src/*.so
src/*.dll
notes.txt
inst/doc
.DS_Store
doc
Meta
.DS_Store

28
.travis.yml

@ -1,11 +1,30 @@
language: r
warnings_are_errors: true
cache: packages
latex: false
fortran: false
sudo: required
matrix:
include:
- os: linux
dist: precise
sudo: false
before_install:
- mkdir -p ~/.R
- echo 'CXX1X=g++ -std=c++0x -g -O2 -fPIC' > ~/.R/Makevars
- os: linux
dist: precise
sudo: false
- os: linux
dist: trusty
sudo: required
env: R_CODECOV=true
env:
global:
- CRAN: https://cran.rstudio.com
- CRAN: http://cran.rstudio.com
addons:
apt:
@ -13,6 +32,9 @@ addons:
- libhunspell-dev
- libpoppler-cpp-dev
r_github_packages:
- jimhester/covr
after_success:
- if [[ "${R_CODECOV}" ]]; then R -e 'covr::codecov()'; fi

4
CRAN-RELEASE

@ -1,2 +1,2 @@
This package was submitted to CRAN on 2020-03-06.
Once it is accepted, delete this file and tag the release (commit a599f17a1d).
This package was submitted to CRAN on 2019-01-20.
Once it is accepted, delete this file and tag the release (commit e42d295063).

17
DESCRIPTION

@ -1,8 +1,8 @@
Package: hrbrthemes
Type: Package
Title: Additional Themes, Theme Components and Utilities for 'ggplot2'
Version: 0.8.6
Date: 2020-07-01
Version: 0.6.0
Date: 2019-01-20
Authors@R: c(
person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-5670-2640")),
@ -14,8 +14,6 @@ Authors@R: c(
person("Google", comment = "Roboto Condensed & Titillium Web Fonts",
role = c("cph")),
person("IBM", comment = "Plex Sans Font", role = c("cph")),
person("Goldman Sachs", comment = "Goldman Sans Font", role = c("cph")),
person("Impallari Type", comment = "Public Sans Font", role = c("cph")),
person("Jacob", "Barnett", email = "jacob.r.barnett@gmail.com", role = c("ctb")),
person("Thomas J.", "Leeper", role = c("ctb"), email = "thosjleeper@gmail.com",
comment = c(ORCID = "0000-0003-4097-6326")),
@ -25,9 +23,8 @@ 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 along with a copy of the 'IBM' 'Plex Sans' <https://github.com/IBM/type>,
'Titillium Web' <https://fonts.google.com/specimen/Titillium+Web>, and
'Public Sans' <https://github.com/uswds/public-sans/> fonts
is also included along with a copy of the 'IBM' 'Plex Sans' <https://github.com/IBM/type>
and 'Titillium Web' <https://fonts.google.com/specimen/Titillium+Web> fonts
are also included to support their respective typography-oriented themes.
URL: http://github.com/hrbrmstr/hrbrthemes
BugReports: https://github.com/hrbrmstr/hrbrthemes/issues
@ -45,9 +42,9 @@ Suggests:
vdiffr,
svglite
Depends:
R (>= 3.4.0)
R (>= 3.2.0)
Imports:
ggplot2 (>= 3.3.0),
ggplot2 (>= 2.2.1),
grDevices,
grid,
scales,
@ -58,5 +55,5 @@ Imports:
tools,
magrittr,
gdtools
RoxygenNote: 7.1.1
RoxygenNote: 6.1.1
VignetteBuilder: knitr

26
NAMESPACE

@ -3,26 +3,10 @@
export("%>%")
export(flush_ticks)
export(font_an)
export(font_es)
export(font_es_bold)
export(font_es_light)
export(font_gs)
export(font_inter_bold)
export(font_inter_italic)
export(font_inter_medium)
export(font_inter_medium_italic)
export(font_inter_semibold)
export(font_inter_thin)
export(font_inter_thin_italic)
export(font_ps)
export(font_ps_light)
export(font_pub)
export(font_pub_bold)
export(font_pub_light)
export(font_pub_thin)
export(font_rc)
export(font_rc_light)
export(font_th)
export(font_tw)
export(font_tw_bold)
export(font_tw_light)
@ -31,13 +15,8 @@ export(ft_geom_defaults)
export(ft_pal)
export(ft_text_col)
export(gg_check)
export(import_econ_sans)
export(import_goldman_sans)
export(import_inter)
export(import_plex_sans)
export(import_public_sans)
export(import_roboto_condensed)
export(import_tinyhand)
export(import_titillium_web)
export(ipsum)
export(ipsum_pal)
@ -55,15 +34,10 @@ export(scale_y_comma)
export(scale_y_percent)
export(theme_ft_rc)
export(theme_ipsum)
export(theme_ipsum_es)
export(theme_ipsum_gs)
export(theme_ipsum_inter)
export(theme_ipsum_ps)
export(theme_ipsum_pub)
export(theme_ipsum_rc)
export(theme_ipsum_tw)
export(theme_modern_rc)
export(theme_tinyhand)
export(update_geom_font_defaults)
import(extrafont)
import(ggplot2)

19
NEWS.md

@ -1,22 +1,3 @@
# hrbrthemes 0.8.0
- Changes to conform to forthcoming {ggplot2} release
# hrbrthemes 0.7.2
- Further enhancements to the `scale_[xy]_… functions` to support passing in
of all the `…_format()` params to make them more flexible
# hrbrthemes 0.7.1
- Small modification to percent scales to account for
changes in {ggplot2}
- Additional precision in setting various theme elements
# hrbrthemes 0.7.0
- fix CRAN check errors
# hrbrthemes 0.6.0
- new themes & fonts

2
R/color.r

@ -10,7 +10,7 @@ ipsum_pal <- function() { manual_pal(ipsum_palette) }
#' Discrete color & fill scales based on the ipsum palette
#'
#' See [ipsum_pal()].
#' See [ipsum_pal]().
#'
#' @md
#' @inheritDotParams ggplot2::discrete_scale -expand -position

245
R/econ-sans.R

@ -1,245 +0,0 @@
#' A precise & pristine [ggplot2] theme with opinionated defaults and an emphasis on typoghraphy
#'
#' You should [import_econ_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 Econ Sans Condensed?:
#' It's free, has tolerable kerning pairs and multiple weights. It's also different
#' than Arial Narrow and the fonts most folks use in ggplot2 charts.
#'
#' @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 panel_spacing panel spacing (use `unit()`)
#' @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 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_ipsum_es()
#'
#' # seminal bar chart
#'
#' # note: may need to make this font_es on Windows
#' update_geom_font_defaults(family=font_es_light)
#'
#' count(mpg, class) %>%
#' ggplot(aes(class, n)) +
#' geom_col() +
#' geom_text(aes(label=n), nudge_y=3) +
#' labs(x="Fuel efficiency (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_es(grid="Y") +
#' theme(axis.text.y=element_blank())
#' }
theme_ipsum_es <- function(
base_family="EconSansCndReg", base_size = 11.5,
plot_title_family="EconSansCndBol", plot_title_size = 18,
plot_title_face="bold", plot_title_margin = 10,
subtitle_family=if (.Platform$OS.type == "windows") "EconSansCndLig" else "EconSansCndLig",
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") "EconSansCndLig" else "EconSansCndLig",
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),
panel_spacing = grid::unit(2, "lines"),
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())
ret <- ret + theme(plot.margin = plot_margin)
ret <- ret + theme(panel.spacing = panel_spacing)
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())
ret <- ret + theme(panel.grid.major = element_blank())
ret <- ret + theme(panel.grid.major.x = element_blank())
ret <- ret + theme(panel.grid.major.y = element_blank())
ret <- ret + theme(panel.grid.minor = element_blank())
ret <- ret + theme(panel.grid.minor.x = element_blank())
ret <- ret + theme(panel.grid.minor.y = 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 = element_text(size = axis_text_size, margin = margin(t = 0, r = 0)))
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(axis.title.y.right = element_text(
hjust = yj, size = axis_title_size, angle = 90,
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(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
}
#' Import Roboto Condensed font for use in charts
#'
#' Roboto Condensed is a trademark of Google.
#'
#' 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_econ_sans <- function() {
es_font_dir <- system.file("fonts", "econ-sans", package="hrbrthemes")
#
# suppressWarnings(suppressMessages(extrafont::font_import(es_font_dir, prompt=FALSE)))
#
# message(
# "You will likely need to install these fonts on your system as well.\n\n",
# "You can find them in [", es_font_dir, "]"
# )
}
#' @rdname EconSansCondensed
#' @md
#' @title Econ Sans Condensed font name R variable aliases
#' @description `font_es` == "`EconSansCndLig`"
#' @format length 1 character vector
#' @export
font_es <- "EconSansCndReg"
#' @rdname EconSansCondensed
#' @md
#' @note `font_es_bold` (a.k.a. "`EconSansCndBol`") is not available on
#' Windows and will throw a warning if used in plots.
#' @description `font_es_bold` == "`EconSansCndBol`"
#' @export
font_es_bold <- "EconSansCndBol"
#' @rdname EconSansCondensed
#' @md
#' @note `font_es_light` (a.k.a. "`EconSansCndLig`") is not available on
#' Windows and will throw a warning if used in plots.
#' @description `font_es_light` == "`EconSansCndLig`"
#' @export
font_es_light <- "EconSansCndLig"

3
R/ft.R

@ -21,6 +21,7 @@ white = "#ffffff"
#' @export
ft_text_col <- "#929299"
#' @inheritParams hrbrthemes::theme_ipsum_rc
#' @rdname theme_ipsum_rc
#' @export
theme_ft_rc <- function (base_family = "Roboto Condensed", base_size = 11.5,
@ -202,7 +203,7 @@ ft_pal <- function() {
#' Discrete color & fill scales based on the FT palette
#'
#' See [ft_pal()].
#' See [ft_pal]().
#'
#' @md
#' @inheritDotParams ggplot2::discrete_scale -expand -position

209
R/goldmansans.R

@ -1,209 +0,0 @@
#' A precise & pristine [ggplot2] theme with opinionated defaults and an emphasis on typoghraphy
#'
#' You should [import_goldman_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 Goldman Sans?:
#' See <https://design.gs.com/d/story/goldman-sans/>.
#'
#' @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 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_ipsum_gs()
#'
#' # seminal bar chart
#'
#' update_geom_font_defaults(family=font_gs_light)
#'
#' count(mpg, class) %>%
#' ggplot(aes(class, n)) +
#' geom_col() +
#' geom_text(aes(label=n), nudge_y=3) +
#' labs(x="Fuel efficiency (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_gs(grid="Y") +
#' theme(axis.text.y=element_blank())
#' }
theme_ipsum_gs <- function(
base_family="Goldman Sans Condensed",
base_size = 11.5,
plot_title_family="Goldman Sans Condensed",
plot_title_size = 18,
plot_title_face="bold",
plot_title_margin = 10,
subtitle_family=if (.Platform$OS.type == "windows") "Goldman Sans Condensed" else "Goldman Sans Condensed",
subtitle_size = 13,
subtitle_face = "plain",
subtitle_margin = 15,
strip_text_family = "Goldman Sans Condensed",
strip_text_size = 12,
strip_text_face = "bold",
caption_family=if (.Platform$OS.type == "windows") "Goldman Sans Condensed" else "Goldman Sans Condensed",
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(axis.title.y.right=element_text(hjust=yj, size=axis_title_size, angle=90,
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 Goldman Sans font for use in charts
#'
#' Goldman Sans is a trademark of Goldman Sachs and distributed under the
#' [Goldman Sachs Restricted Font License](https://design.gs.com/d/legal/goldman-sans-license/).
#'
#' 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_goldman_sans <- function() {
gs_font_dir <- system.file("fonts", "goldman-sans", package="hrbrthemes")
# suppressWarnings(suppressMessages(extrafont::font_import(gs_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]",
# gs_font_dir)
# )
}
#' @rdname GoldmanSans
#' @md
#' @title Goldman Sans font name R variable aliases
#' @description `font_gs` == "`Goldman Sans Condensed`"
#' @format length 1 character vector
#' @export
font_gs <- "Goldman Sans Condensed"

2
R/hrbrthemes-package.R

@ -26,7 +26,7 @@
#' @importFrom gdtools set_dummy_conf
#' @import rmarkdown knitr htmltools
#' @importFrom tools file_path_sans_ext
"_PACKAGE"
NULL
#' hrbrthemes exported operators
#'

259
R/inter.R

@ -1,259 +0,0 @@
#' A precise & pristine [ggplot2] theme with opinionated defaults and an emphasis on typoghraphy
#'
#' You should [import_inter()] 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 Inter?:
#' See <https://design.gs.com/d/story/goldman-sans/>.
#'
#' @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 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_ipsum_inter()
#'
#' # seminal bar chart
#'
#' update_geom_font_defaults(family=font_inter_medium)
#'
#' count(mpg, class) %>%
#' ggplot(aes(class, n)) +
#' geom_col() +
#' geom_text(aes(label=n), nudge_y=3) +
#' labs(x="Fuel efficiency (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_inter(grid="Y") +
#' theme(axis.text.y=element_blank())
#' }
theme_ipsum_inter <- function(
base_family="Inter-Medium",
base_size = 10,
plot_title_family="Inter-Bold",
plot_title_size = 16,
plot_title_face="bold",
plot_title_margin = 8,
subtitle_family="Inter-Light",
subtitle_size = 12,
subtitle_face = "plain",
subtitle_margin = 13,
strip_text_family = "Inter-SemiBold",
strip_text_size = 12,
strip_text_face = "bold",
caption_family="Inter-Thin",
caption_size = 9,
caption_face = "plain",
caption_margin = 10,
axis_text_family = "Inter-Light",
axis_text_face = "plain",
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(axis.title.y.right=element_text(hjust=yj, size=axis_title_size, angle=90,
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 Inter font for use in charts
#'
#' Inter is Copyright (c) 2016-2020 The Inter Project Authors
#' (<https://rsms.me/inter/>).
#'
#' 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_inter <- function() {
inter_font_dir <- system.file("fonts", "inter", package="hrbrthemes")
suppressWarnings(suppressMessages(extrafont::font_import(inter_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]",
inter_font_dir)
)
}
#' @rdname Inter
#' @md
#' @title Inter font name R variable aliases
#' @description `font_inter_thin` == "`Inter-Thin`"
#' @format length 1 character vector
#' @export
font_inter_thin <- "Inter-Thin"
#' @rdname Inter
#' @md
#' @title Inter font name R variable aliases
#' @description `font_inter_thin_italic` == "`Inter-ThinItalic`"
#' @format length 1 character vector
#' @export
font_inter_thin_italic <- "Inter-ThinItalic"
#' @rdname Inter
#' @md
#' @title Inter font name R variable aliases
#' @description `font_inter_medium` == "`Inter-Medium`"
#' @format length 1 character vector
#' @export
font_inter_medium <- "Inter-Medium"
#' @rdname Inter
#' @md
#' @title Inter font name R variable aliases
#' @description `font_inter_medium_italic` == "`Inter-MediumItalic`"
#' @format length 1 character vector
#' @export
font_inter_medium_italic <- "Inter-MediumItalic"
#' @rdname Inter
#' @md
#' @title Inter font name R variable aliases
#' @description `font_inter_semibold` == "`Inter-SemiBold`"
#' @format length 1 character vector
#' @export
font_inter_semibold <- "Inter-SemiBold"
#' @rdname Inter
#' @md
#' @title Inter font name R variable aliases
#' @description `font_inter_bold` == "`Inter-Bold`"
#' @format length 1 character vector
#' @export
font_inter_bold <- "Inter-Bold"
#' @rdname Inter
#' @md
#' @title Inter font name R variable aliases
#' @description `font_inter_italic` == "`Inter-Italic`"
#' @format length 1 character vector
#' @export
font_inter_italic <- "Inter-Italic"

1
R/ipsum-pdf.R

@ -2,6 +2,7 @@
#'
#' Template for creating an R markdown documents with an emphasis on typography
#'
#' @inheritParams rmarkdown::pdf_document
#' @param ... Arguments to \code{rmarkdown::pdf_document}
#'
#' @return R Markdown output format to pass to \code{\link[rmarkdown:render]{render}}

1
R/modern.r

@ -1,3 +1,4 @@
#' @inheritParams hrbrthemes::theme_ipsum_rc
#' @rdname theme_ipsum_rc
#' @export
theme_modern_rc <- function (base_family = "Roboto Condensed", base_size = 11.5,

20
R/plexsans.R

@ -1,6 +1,6 @@
#' 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
#' 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
@ -37,7 +37,7 @@
#' # seminal scatterplot
#' ggplot(mtcars, aes(mpg, wt)) +
#' geom_point() +
#' labs(x="Fuel efficiency (mpg)", y="Weight (tons)",
#' 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'") +
@ -52,7 +52,7 @@
#' ggplot(aes(class, n)) +
#' geom_col() +
#' geom_text(aes(label=n), nudge_y=3) +
#' labs(x="Fuel efficiency (mpg)", y="Weight (tons)",
#' 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'") +
@ -184,13 +184,13 @@ import_plex_sans <- function() {
ps_font_dir <- system.file("fonts", "plex-sans", package="hrbrthemes")
# suppressWarnings(suppressMessages(extrafont::font_import(ps_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]",
# ps_font_dir)
# )
suppressWarnings(suppressMessages(extrafont::font_import(ps_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]",
ps_font_dir)
)
}

228
R/public-sans.R

@ -1,228 +0,0 @@
#' A precise & pristine [ggplot2] theme with opinionated defaults and an emphasis on typoghraphy
#'
#' You should [import_public_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 Public Sans?:
#'
#' See [the design principles](https://github.com/uswds/public-sans#design-principles).
#'
#' @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 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_ipsum_pub()
#'
#' # seminal bar chart
#'
#' update_geom_font_defaults(family=font_pub)
#'
#' count(mpg, class) %>%
#' ggplot(aes(class, n)) +
#' geom_col() +
#' geom_text(aes(label=n), nudge_y=3) +
#' labs(x="Fuel efficiency (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_pub(grid="Y") +
#' theme(axis.text.y=element_blank())
#' }
theme_ipsum_pub <- function(
base_family="Public Sans", base_size = 10.5,
plot_title_family=if (.Platform$OS.type == "windows") "Public Sans" else "Public Sans Bold",
plot_title_size = 18,
plot_title_face="bold",
plot_title_margin = 10,
subtitle_family=if (.Platform$OS.type == "windows") "Public Sans Thin" else "Public Sans Thin",
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") "Public Sans Thin" else "Public Sans Thin",
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_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(axis.title.y.right=element_text(hjust=yj, size=axis_title_size, angle=90,
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 Public Sans font for use in charts
#'
#' Public Sans is Copyright 2015 Impallari Type and licensed 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_public_sans <- function() {
pub_font_dir <- system.file("fonts", "public-sans", package="hrbrthemes")
# suppressWarnings(suppressMessages(extrafont::font_import(pub_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]",
# pub_font_dir)
# )
}
#' @rdname PublicSans
#' @md
#' @title Public Sans font name R variable aliases
#' @description `font_pub` == "`Public Sans`"
#' @format length 1 character vector
#' @export
font_pub <- "Public Sans"
#' @rdname PublicSans
#' @md
#' @note `font_pub_bold` (a.k.a. "`Public Sans Bold`") is not available on
#' Windows and will throw a warning if used in plots.
#' @description `font_pub_bold` == "`Public Sans Bold`"
#' @export
font_pub_bold <- "Public Sans Bold"
#' @rdname PublicSans
#' @md
#' @description `font_pub_light` == "`Public Sans Light`"
#' @export
font_pub_light <- "Public Sans Light"
#' @rdname PublicSans
#' @md
#' @description `font_pub_thin` == "`Public Sans Thin`"
#' @export
font_pub_thin <- "Public Sans Thin"

143
R/roboto-condensed.r

@ -1,6 +1,6 @@
#' A precise & pristine [ggplot2] theme with opinionated defaults and an emphasis on typoghraphy
#'
#' You should [import_roboto_condensed()] first and also install the fonts on your
#' You should [import_roboto_condensed]() 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
@ -24,7 +24,6 @@
#' @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 panel_spacing panel spacing (use `unit()`)
#' @param grid_col grid color
#' @param grid panel grid (`TRUE`, `FALSE`, or a combination of `X`, `x`, `Y`, `y`)
#' @param axis_col axis color
@ -38,7 +37,7 @@
#' # seminal scatterplot
#' ggplot(mtcars, aes(mpg, wt)) +
#' geom_point() +
#' labs(x="Fuel efficiency (mpg)", y="Weight (tons)",
#' 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'") +
@ -53,7 +52,7 @@
#' ggplot(aes(class, n)) +
#' geom_col() +
#' geom_text(aes(label=n), nudge_y=3) +
#' labs(x="Fuel efficiency (mpg)", y="Weight (tons)",
#' 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'") +
@ -78,59 +77,51 @@ theme_ipsum_rc <- function(
axis_title_face = "plain",
axis_title_just = "rt",
plot_margin = margin(30, 30, 30, 30),
panel_spacing = grid::unit(2, "lines"),
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 <- 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())
ret <- ret + theme(plot.margin = plot_margin)
ret <- ret + theme(panel.spacing = panel_spacing)
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))
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())
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())
ret <- ret + theme(panel.grid.major = element_blank())
ret <- ret + theme(panel.grid.major.x = element_blank())
ret <- ret + theme(panel.grid.major.y = element_blank())
ret <- ret + theme(panel.grid.minor = element_blank())
ret <- ret + theme(panel.grid.minor.x = element_blank())
ret <- ret + theme(panel.grid.minor.y = element_blank())
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))
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())
ret <- ret + theme(axis.line.x=element_blank())
} else {
ret <- ret + theme(axis.line.x = element_line(color = axis_col, size = 0.15))
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())
ret <- ret + theme(axis.line.y=element_blank())
} else {
ret <- ret + theme(axis.line.y = 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.x = element_line(color = axis_col, size = 0.15))
ret <- ret + theme(axis.line.y = element_line(color = axis_col, size = 0.15))
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())
ret <- ret + theme(axis.line=element_blank())
}
if (!ticks) {
@ -138,53 +129,37 @@ theme_ipsum_rc <- function(
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 = 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 = element_text(size = axis_text_size, margin = margin(t = 0, r = 0)))
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(axis.title.y.right = element_text(
hjust = yj, size = axis_title_size, angle = 90,
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(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
))
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(axis.title.y.right=element_text(hjust=yj, size=axis_title_size, angle=90,
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
@ -209,13 +184,13 @@ import_roboto_condensed <- function() {
rc_font_dir <- system.file("fonts", "roboto-condensed", 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)
# )
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)
)
}

347
R/scales.r

@ -27,12 +27,13 @@ is.formula <- function (x) { inherits(x, "formula") }
#' 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 labels One of:
#' - `NULL` for no labels
#' - `waiver()` for the default labels computed by the
#' transformation object
#' - A character vector giving labels (must be same length as `breaks`)
#' - A function that takes the breaks as input and returns labels
#' as output
#' @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
@ -49,291 +50,89 @@ is.formula <- function (x) { inherits(x, "formula") }
#' 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
scale_x_percent <- function (name = waiver(), breaks = waiver(), minor_breaks = waiver(),
labels = scales::percent, limits = NULL, expand = c(0.01,0), oob = censor,
na.value = NA_real_, trans = "identity", position = "bottom",
sec.axis = waiver()) {
sc <- ggplot2::continuous_scale(c("x", "xmin", "xmax", "xend", "xintercept",
"xmin_final", "xmax_final", "xlower", "xmiddle", "xupper"),
"position_c", identity, name = name, breaks = breaks,
minor_breaks = minor_breaks, labels = labels, limits = limits,
expand = expand, oob = oob, na.value = na.value, trans = trans,
guide = "none", position = position, super = ScaleContinuousPosition)
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()'")
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
scale_y_percent <- function (name = waiver(), breaks = waiver(), minor_breaks = waiver(),
labels = scales::percent, limits = NULL, expand = c(0.01,0), oob = censor,
na.value = NA_real_, trans = "identity", position = "left",
sec.axis = waiver()) {
sc <- ggplot2::continuous_scale(c("y", "ymin", "ymax", "yend", "yintercept",
"ymin_final", "ymax_final", "lower", "middle", "upper"),
"position_c", identity, name = name, breaks = breaks,
minor_breaks = minor_breaks, labels = labels, limits = limits,
expand = expand, oob = oob, na.value = na.value, trans = trans,
guide = "none", position = position, super = ScaleContinuousPosition)
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
scale_x_comma <- function (name = waiver(), breaks = waiver(), minor_breaks = waiver(),
labels = scales::comma, limits = NULL, expand = c(0.01,0), oob = censor,
na.value = NA_real_, trans = "identity", position = "bottom",
sec.axis = waiver()) {
sc <- ggplot2::continuous_scale(c("x", "xmin", "xmax", "xend", "xintercept",
"xmin_final", "xmax_final", "xlower", "xmiddle", "xupper"),
"position_c", identity, name = name, breaks = breaks,
minor_breaks = minor_breaks, labels = labels, limits = limits,
expand = expand, oob = oob, na.value = na.value, trans = trans,
guide = "none", position = position, super = ScaleContinuousPosition)
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()'")
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
}
scale_y_comma <- function (name = waiver(), breaks = waiver(), minor_breaks = waiver(),
labels = scales::comma, limits = NULL, expand = c(0.01,0), oob = censor,
na.value = NA_real_, trans = "identity", position = "left",
sec.axis = waiver()) {
sc <- ggplot2::continuous_scale(c("y", "ymin", "ymax", "yend", "yintercept",
"ymin_final", "ymax_final", "lower", "middle", "upper"),
"position_c", identity, name = name, breaks = breaks,
minor_breaks = minor_breaks, labels = labels, limits = limits,
expand = expand, oob = oob, na.value = na.value, trans = trans,
guide = "none", position = position, super = ScaleContinuousPosition)
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
}

382
R/theme-ipsum.r

@ -1,191 +1,191 @@
#' A precise & pristine [ggplot2] theme with opinionated defaults and an emphasis on typography
#'
#' Also has a "dark" / "modern" version for the new RStudio theme
#'
#' @md
#' @section Why Arial Narrow?:
#' First and foremost, Arial Narrow is generally installed by default or readily
#' available on any modern system, so it's "free"-ish; plus, it is a condensed font
#' with solid default kerning pairs and geometric numbers.
#'
#' @section Building upon `theme_ipsum`:
#' The function is setup in such a way that you can customize your own one by just
#' wrapping the call and changing the parameters. See source for examples.
#'
#' @section Gotchas:
#' There are distinctions between font names and various devices. Names that work
#' for display graphics devices and bitmap ones such as `png` may not work well
#' for PostScript or PDF ones. You may need two versions of a font-based
#' theme function for them to work in a particular situation. This situation
#' usually only arises when using a newer font with many weights but somewhat
#' irregular internal font name patterns.
#'
#' 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
#' @param base_family,base_size base font family and size
#' @param plot_title_family,plot_title_face,plot_title_size,plot_title_margin plot title family, face, size and margi
#' @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 justification, one of `[blmcrt]`
#' @param plot_margin plot margin (specify with `ggplot2::margin()`)
#' @param grid_col,axis_col grid & axis colors; both default to `#cccccc`
#' @param grid panel grid (`TRUE`, `FALSE`, or a combination of `X`, `x`, `Y`, `y`)
#' @param axis_text_size font size of axis text
#' @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 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_ipsum()
#'
#' # seminal bar chart
#'
#' update_geom_font_defaults()
#'
#' count(mpg, class) %>%
#' ggplot(aes(class, n)) +
#' geom_col() +
#' geom_text(aes(label=n), nudge_y=3) +
#' labs(x="Fuel efficiency (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(grid="Y") +
#' theme(axis.text.y=element_blank())
#' }
theme_ipsum <- function(base_family="Arial Narrow", base_size = 11.5,
plot_title_family=base_family, plot_title_size = 18,
plot_title_face="bold", plot_title_margin = 10,
subtitle_family=base_family, subtitle_size = 12,
subtitle_face = "plain", subtitle_margin = 15,
strip_text_family = base_family, strip_text_size = 12,
strip_text_face = "plain",
caption_family = base_family, caption_size = 9,
caption_face = "italic", caption_margin = 10,
axis_text_size = base_size,
axis_title_family = subtitle_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="#2b2b2b", 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(axis.title.y.right=element_text(hjust=yj, size=axis_title_size, angle=90,
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
}
#' Update matching font defaults for text geoms
#'
#' Updates [ggplot2::geom_label] and [ggplot2::geom_text] font defaults
#'
#' @param family,face,size,color font family name, face, size and color
#' @export
update_geom_font_defaults <- function(family="Arial Narrow", face="plain", size=3.5,
color = "#2b2b2b") {
update_geom_defaults("text", list(family=family, face=face, size=size, color=color))
update_geom_defaults("label", list(family=family, face=face, size=size, color=color))
}
#' @rdname ArialNarrow
#' @md
#' @title Arial Narrow font name R variable aliases
#' @description `font_an` == "`Arial Narrow`"
#' @format length 1 character vector
#' @export
font_an <- "Arial Narrow"
#' A precise & pristine [ggplot2] theme with opinionated defaults and an emphasis on typography
#'
#' Also has a "dark" / "modern" version for the new RStudio theme
#'
#' @md
#' @section Why Arial Narrow?:
#' First and foremost, Arial Narrow is generally installed by default or readily
#' available on any modern system, so it's "free"-ish; plus, it is a condensed font
#' with solid default kerning pairs and geometric numbers.
#'
#' @section Building upon `theme_ipsum`:
#' The function is setup in such a way that you can customize your own one by just
#' wrapping the call and changing the parameters. See source for examples.
#'
#' @section Gotchas:
#' There are distinctions between font names and various devices. Names that work
#' for display graphics devices and bitmap ones such as `png` may not work well
#' for PostScript or PDF ones. You may need two versions of a font-based
#' theme function for them to work in a particular situation. This situation
#' usually only arises when using a newer font with many weights but somewhat
#' irregular internal font name patterns.
#'
#' 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
#' @param base_family,base_size base font family and size
#' @param plot_title_family,plot_title_face,plot_title_size,plot_title_margin plot title family, face, size and margi
#' @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 justification, one of `[blmcrt]`
#' @param plot_margin plot margin (specify with [ggplot2::margin()])
#' @param grid_col,axis_col grid & axis colors; both default to `#cccccc`
#' @param grid panel grid (`TRUE`, `FALSE`, or a combination of `X`, `x`, `Y`, `y`)
#' @param axis_text_size font size of axis text
#' @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()
#'
#' # seminal bar chart
#'
#' update_geom_font_defaults()
#'
#' count(mpg, class) %>%
#' ggplot(aes(class, n)) +
#' geom_col() +
#' geom_text(aes(label=n), nudge_y=3) +
#' labs(x="Fuel efficiency (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(grid="Y") +
#' theme(axis.text.y=element_blank())
#' }
theme_ipsum <- function(base_family="Arial Narrow", base_size = 11.5,
plot_title_family=base_family, plot_title_size = 18,
plot_title_face="bold", plot_title_margin = 10,
subtitle_family=base_family, subtitle_size = 12,
subtitle_face = "plain", subtitle_margin = 15,
strip_text_family = base_family, strip_text_size = 12,
strip_text_face = "plain",
caption_family = base_family, caption_size = 9,
caption_face = "italic", caption_margin = 10,
axis_text_size = base_size,
axis_title_family = subtitle_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="#2b2b2b", 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(axis.title.y.right=element_text(hjust=yj, size=axis_title_size, angle=90,
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
}
#' Update matching font defaults for text geoms
#'
#' Updates [ggplot2::geom_label] and [ggplot2::geom_text] font defaults
#'
#' @param family,face,size,color font family name, face, size and color
#' @export
update_geom_font_defaults <- function(family="Arial Narrow", face="plain", size=3.5,
color = "#2b2b2b") {
update_geom_defaults("text", list(family=family, face=face, size=size, color=color))
update_geom_defaults("label", list(family=family, face=face, size=size, color=color))
}
#' @rdname ArialNarrow
#' @md
#' @title Arial Narrow font name R variable aliases
#' @description `font_an` == "`Arial Narrow`"
#' @format length 1 character vector
#' @export
font_an <- "Arial Narrow"

179
R/tinyhand.R

@ -1,179 +0,0 @@
#' @rdname TinyHand
#' @md
#' @title TinyHand Web font name R variable aliases
#' @description `font_th` == "`BF Tiny Hand`"
#' @format length 1 character vector
#' @export
font_th <- "BFTinyHand-Regular"
#' Something you should never use.
#'
#' You should [import_tinyhand()] 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 Titillium Web?:
#' It's free, has tolerable kerning pairs and multiple weights. It's also different
#' than Arial Narrow and the fonts most folks use in ggplot2 charts.
#'
#' @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
theme_tinyhand <- function(
base_family=font_th, base_size = 10.5,
plot_title_family=font_th,
plot_title_size = 18,
plot_title_face="bold",
plot_title_margin = 10,
subtitle_family=font_th,
subtitle_size = 13,
subtitle_face = "plain",
subtitle_margin = 15,
strip_text_family = base_family,
strip_text_size = 12,
strip_text_face = "plain",
caption_family=font_th,
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_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(axis.title.y.right=element_text(hjust=yj, size=axis_title_size, angle=90,
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 Titillium Web font for use in charts
#'
#' Titillium Web is a trademark of Google.
#'
#' 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_tinyhand <- function() {
th_font_dir <- system.file("fonts", "tinyhand", package="hrbrthemes")
# suppressWarnings(suppressMessages(extrafont::font_import(th_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]",
# th_font_dir)
# )
}

21
R/titillium-web.R

@ -1,6 +1,6 @@
#' A precise & pristine [ggplot2] theme with opinionated defaults and an emphasis on typoghraphy
#'
#' You should [import_titillium_web()] first and also install the fonts on your
#' You should [import_titillium_web]() 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
@ -37,7 +37,7 @@
#' # seminal scatterplot
#' ggplot(mtcars, aes(mpg, wt)) +
#' geom_point() +
#' labs(x="Fuel efficiency (mpg)", y="Weight (tons)",
#' 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'") +
@ -52,7 +52,7 @@
#' ggplot(aes(class, n)) +
#' geom_col() +
#' geom_text(aes(label=n), nudge_y=3) +
#' labs(x="Fuel efficiency (mpg)", y="Weight (tons)",
#' 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'") +
@ -188,13 +188,13 @@ import_titillium_web <- function() {
tw_font_dir <- system.file("fonts", "titillium-web", package="hrbrthemes")
# suppressWarnings(suppressMessages(extrafont::font_import(tw_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]",
# tw_font_dir)
# )
suppressWarnings(suppressMessages(extrafont::font_import(tw_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]",
tw_font_dir)
)
}
@ -221,3 +221,4 @@ font_tw_bold <- "Titillium Web Bold"
#' @description `font_tw_light` == "`Titillium Web Light`"
#' @export
font_tw_light <- "Titillium Web Light"

43
R/zzz.r

@ -1,14 +1,5 @@
.onAttach <- function(libname, pkgname) {
tw_font_dir <- system.file("fonts", "titillium-web", package="hrbrthemes")
gs_font_dir <- system.file("fonts", "goldman-sans", package="hrbrthemes")
es_font_dir <- system.file("fonts", "econ-sans", package="hrbrthemes")
rc_font_dir <- system.file("fonts", "roboto-condensed", package="hrbrthemes")
pub_font_dir <- system.file("fonts", "public-sans", package="hrbrthemes")
ps_font_dir <- system.file("fonts", "plex-sans", package="hrbrthemes")
th_font_dir <- system.file("fonts", "tinyhand", package="hrbrthemes")
# if (interactive()) {
# packageStartupMessage(paste0("hrbrthemes is under *active* development. ",
# "See https://github.com/hrbrmstr/hrbrthemes for info/news."))
@ -16,22 +7,22 @@
# Suggestion by @alexwhan
# if (.Platform$OS.type == "windows") { # nocov start
# if (interactive()) packageStartupMessage("Registering Windows fonts with R")
# extrafont::loadfonts("win", quiet = TRUE)
# }
#
# if (getOption("hrbrthemes.loadfonts", default = FALSE)) {
# if (interactive()) packageStartupMessage("Registering PDF & PostScript fonts with R")
# extrafont::loadfonts("pdf", quiet = TRUE)
# extrafont::loadfonts("postscript", quiet = TRUE)
# }
#
# 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(" Please use hrbrthemes::import_roboto_condensed() to install Roboto Condensed and")
# packageStartupMessage(" if Arial Narrow is not on your system, please see https://bit.ly/arialnarrow")
# } # nocov end
if (.Platform$OS.type == "windows") { # nocov start
if (interactive()) packageStartupMessage("Registering Windows fonts with R")
extrafont::loadfonts("win", quiet = TRUE)
}
if (getOption("hrbrthemes.loadfonts", default = FALSE)) {
if (interactive()) packageStartupMessage("Registering PDF & PostScript fonts with R")
extrafont::loadfonts("pdf", quiet = TRUE)
extrafont::loadfonts("postscript", quiet = TRUE)
}
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(" Please use hrbrthemes::import_roboto_condensed() to install Roboto Condensed and")
packageStartupMessage(" if Arial Narrow is not on your system, please see https://bit.ly/arialnarrow")
} # nocov end
}

96
README.Rmd

@ -1,26 +1,22 @@
---
output: rmarkdown::github_document
---
```{r pkg-knitr-opts, include=FALSE}
hrbrpkghelpr::global_opts()
```{r, echo = FALSE}
knitr::opts_chunk$set(collapse=TRUE, comment="##", fig.retina=2, fig.path = "README_figs/README-")
```
```{r badges, results='asis', echo=FALSE, cache=FALSE}
hrbrpkghelpr::stinking_badges(
extra_lines = c(
"![downloads](https://cranlogs.r-pkg.org/badges/grand-total/hrbrthemes)",
"[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.2545422.svg)](https://doi.org/10.5281/zenodo.2545422)"
)
)
```
## hrbrthemes
## `hrbrthemes` : Additional Themes and Theme Components for 'ggplot2'
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)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.2545422.svg)](https://doi.org/10.5281/zenodo.2545422)
----
This is a very focused package that provides typography-centric themes and theme components for ggplot2. It's a an extract/riff of [`hrbrmisc`](https://github.com/hrbrmstr/hrbrmisc) created by request.
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".
@ -28,28 +24,25 @@ The following functions are implemented/objects are exported:
Themes:
- `theme_ipsum`: Arial Narrow
- `theme_ipsum_gs`: Goldman Sans Condensed
- `theme_ipsum_es`: Econ Sans Condensed
- `theme_ipsum_rc`: Roboto Condensed
- `theme_ipsum_ps`: IBM Plex Sans font
- `theme_ipsum_pub`: Public Sans
- `theme_ipsum_tw`: Titilium Web
- `theme_modern_rc`: Roboto Condensed dark theme
- `theme_ft_rc`: Dark theme based on FT's dark theme (Roboto Condensed)
- `theme_ft_rc`: A precise & pristine ggplot2 theme with opinionated defaults and an emphasis on typoghraphy
- `theme_ipsum`: A precise & pristine ggplot2 theme with opinionated defaults and an emphasis on typography
- `theme_ipsum_ps`: A precise & pristine ggplot2 theme with opinionated defaults and an emphasis on typoghraphy
- `theme_ipsum_rc`: A precise & pristine ggplot2 theme with opinionated defaults and an emphasis on typoghraphy
- `theme_ipsum_tw`: A precise & pristine ggplot2 theme with opinionated defaults and an emphasis on typoghraphy
- `theme_modern_rc`: A precise & pristine ggplot2 theme with opinionated defaults and an emphasis on typoghraphy
Scales (that align with various themes):
- `scale_color_ipsum`: Discrete color & fill scales based on the ipsum palette
- `scale_colour_ipsum`: Discrete color & fill scales based on the ipsum palette
- `scale_fill_ipsum`: Discrete color & fill scales based on the ipsum palette
- `scale_color_ft`: Discrete color & fill scales based on the FT palette
- `scale_color_ipsum`: Discrete color & fill scales based on the ipsum palette
- `scale_colour_ft`: Discrete color & fill scales based on the FT palette
- `scale_colour_ipsum`: Discrete color & fill scales based on the ipsum palette
- `scale_fill_ft`: Discrete color & fill scales based on the FT palette
- `scale_x_comma`: X & Y scales with opinionated presets for percent & comma label formats
- `scale_x_percent`: X & Y scales with opinionated presets for percent & comma label formats
- `scale_y_comma`: X & Y scales with opinionated presets for percent & comma label formats
- `scale_y_percent`: X & Y scales with opinionated presets for percent & comma label formats
- `scale_fill_ipsum`: Discrete color & fill scales based on the ipsum palette
- `scale_x_comma`: X & Y scales with opinionated pre-sets for percent & comma label formats
- `scale_x_percent`: X & Y scales with opinionated pre-sets for percent & comma label formats
- `scale_y_comma`: X & Y scales with opinionated pre-sets for percent & comma label formats
- `scale_y_percent`: X & Y scales with opinionated pre-sets for percent & comma label formats
Palettes/Named Colors:
@ -61,17 +54,10 @@ Palettes/Named Colors:
Fonts:
- `font_an`: Arial Narrow font name R variable aliases
- `font_es`: Econ Sans font name R variable aliases
- `font_es_bold`: Econ Sans font name R variable aliases
- `font_es_light`: Econ Sans font name R variable aliases
- `font_rc`: Roboto Condensed font name R variable aliases
- `font_rc_light`: Roboto Condensed font name R variable aliases
- `font_pub`: Public Sans font name R variable aliases
- `font_pub_bold`: Public Sans font name R variable aliases
- `font_pub_light`: Public Sans font name R variable aliases
- `font_pub_thin`: Public Sans font name R variable aliases
- `font_ps`: PlexSans font name R variable aliases
- `font_ps_light`: PlexSans font name R variable aliases
- `font_rc`: Roboto Condensed font name R variable aliases
- `font_rc_light`: Roboto Condensed font name R variable aliases
- `font_tw`: Titillium Web font name R variable aliases
- `font_tw_bold`: Titillium Web font name R variable aliases
- `font_tw_light`: Titillium Web font name R variable aliases
@ -86,7 +72,6 @@ Utilities:
- `flush_ticks`: Makes axis text labels flush on the ends
- `ft_geom_defaults`: Change geom defaults from black to custom lights for the FT theme
- `gg_check`: Spell check ggplot2 plot labels
- `import_econ_sans`: Import Econ Sans Condensed font for use in charts
- `import_plex_sans`: Import IBM Plex Sans font for use in charts
- `import_roboto_condensed`: Import Roboto Condensed font for use in charts
- `import_titillium_web`: Import Titillium Web font for use in charts
@ -95,8 +80,12 @@ Utilities:
### Installation
```{r install-ex, results='asis', echo = FALSE, cache=FALSE}
hrbrpkghelpr::install_block()
```{r eval=FALSE}
devtools::install_github("hrbrmstr/hrbrthemes")
```
```{r message=FALSE, warning=FALSE, error=FALSE, include=FALSE}
options(width=120)
```
### Usage
@ -112,7 +101,7 @@ packageVersion("hrbrthemes")
### Base theme (Arial Narrow)
```{r an}
```{r fig.retina=2}
ggplot(mtcars, aes(mpg, wt)) +
geom_point() +
labs(x="Fuel efficiency (mpg)", y="Weight (tons)",
@ -124,7 +113,7 @@ ggplot(mtcars, aes(mpg, wt)) +
### Roboto Condensed
```{r rc}
```{r fig.retina=2}
ggplot(mtcars, aes(mpg, wt)) +
geom_point() +
labs(x="Fuel efficiency (mpg)", y="Weight (tons)",
@ -136,7 +125,7 @@ ggplot(mtcars, aes(mpg, wt)) +
### New FT Theme!
```{r ft}
```{r ft, fig.retina=2}
ggplot(mtcars, aes(mpg, wt)) +
geom_point(color = ft_cols$yellow) +
labs(x="Fuel efficiency (mpg)", y="Weight (tons)",
@ -148,7 +137,7 @@ ggplot(mtcars, aes(mpg, wt)) +
### IBM Plex Sans
```{r ps, fig.width=10, fig.height=7}
```{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) +
@ -169,7 +158,7 @@ flush_ticks(gg)
### Titillium Web
```{r tw, fig.width=10, fig.height=7}
```{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) +
@ -190,7 +179,7 @@ flush_ticks(gg)
### Scales (Color/Fill)
```{r sc}
```{r fig.retina=2}
ggplot(mtcars, aes(mpg, wt)) +
geom_point(aes(color=factor(carb))) +
labs(x="Fuel efficiency (mpg)", y="Weight (tons)",
@ -203,7 +192,7 @@ ggplot(mtcars, aes(mpg, wt)) +
### Scales (Axis)
```{r ax1}
```{r fig.retina=2}
count(mpg, class) %>%
mutate(pct=n/sum(n)) %>%
ggplot(aes(class, pct)) +
@ -216,7 +205,7 @@ count(mpg, class) %>%
theme_ipsum(grid="Y")
```
```{r ax2, fig.height=6}
```{r fig.retina=2, fig.height=6}
ggplot(uspopage, aes(x=Year, y=Thousands, fill=AgeGroup)) +
geom_area() +
scale_fill_ipsum() +
@ -230,7 +219,7 @@ ggplot(uspopage, aes(x=Year, y=Thousands, fill=AgeGroup)) +
theme(legend.position="bottom")
```
```{r ax3}
```{r fig.retina=2}
update_geom_font_defaults(font_rc_light)
count(mpg, class) %>%
@ -251,7 +240,7 @@ count(mpg, class) %>%
### Spellcheck ggplot2 labels
```{r sp, message=TRUE}
```{r fig.retina=2, message=TRUE}
df <- data.frame(x=c(20, 25, 30), y=c(4, 4, 4), txt=c("One", "Two", "Three"))
ggplot(mtcars, aes(mpg, wt)) +
@ -273,4 +262,5 @@ cloc::cloc_pkg_md()
### Code of Conduct
Please note that this project is released with a Contributor Code of Conduct. 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.

145
README.md

@ -1,34 +1,20 @@
[![Project Status: Active – The project has reached a stable, usable
## `hrbrthemes` : Additional Themes and Theme Components for ‘ggplot2’
[![Project Status: Active - The project has reached a stable, usable
state and is being actively
developed.](https://www.repostatus.org/badges/latest/active.svg)](https://www.repostatus.org/#active)
[![Signed
by](https://img.shields.io/badge/Keybase-Verified-brightgreen.svg)](https://keybase.io/hrbrmstr)
![Signed commit
%](https://img.shields.io/badge/Signed_Commits-100%25-lightgrey.svg)
[![Linux build
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)
[![Coverage
Status](https://codecov.io/gh/hrbrmstr/hrbrthemes/branch/master/graph/badge.svg)](https://codecov.io/gh/hrbrmstr/hrbrthemes)
[![cran
checks](https://cranchecks.info/badges/worst/hrbrthemes)](https://cranchecks.info/pkgs/hrbrthemes)
[![CRAN
status](https://www.r-pkg.org/badges/version/hrbrthemes)](https://www.r-pkg.org/pkg/hrbrthemes)
![Minimal R
Version](https://img.shields.io/badge/R%3E%3D-3.4.0-blue.svg)
![License](https://img.shields.io/badge/License-MIT-blue.svg)
![downloads](https://cranlogs.r-pkg.org/badges/grand-total/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)
[![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.2545422.svg)](https://doi.org/10.5281/zenodo.2545422)
## hrbrthemes
Additional Themes and Theme Components for ‘ggplot2’
-----
This is a very focused package that provides typography-centric themes
and theme components for ggplot2. It’s a an extract/riff of
[`hrbrmisc`](https://github.com/hrbrmstr/hrbrmisc) created by request.
[`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,
@ -43,39 +29,41 @@ The following functions are implemented/objects are exported:
Themes:
- `theme_ipsum`: Arial Narrow
- `theme_ipsum_gs`: Goldman Sans Condensed
- `theme_ipsum_es`: Econ Sans Condensed
- `theme_ipsum_rc`: Roboto Condensed
- `theme_ipsum_ps`: IBM Plex Sans font
- `theme_ipsum_pub`: Public Sans
- `theme_ipsum_tw`: Titilium Web
- `theme_modern_rc`: Roboto Condensed dark theme
- `theme_ft_rc`: Dark theme based on FT’s dark theme (Roboto
Condensed)
- `theme_ft_rc`: A precise & pristine ggplot2 theme with opinionated
defaults and an emphasis on typoghraphy
- `theme_ipsum`: A precise & pristine ggplot2 theme with opinionated
defaults and an emphasis on typography
- `theme_ipsum_ps`: A precise & pristine ggplot2 theme with
opinionated defaults and an emphasis on typoghraphy
- `theme_ipsum_rc`: A precise & pristine ggplot2 theme with
opinionated defaults and an emphasis on typoghraphy
- `theme_ipsum_tw`: A precise & pristine ggplot2 theme with
opinionated defaults and an emphasis on typoghraphy
- `theme_modern_rc`: A precise & pristine ggplot2 theme with
opinionated defaults and an emphasis on typoghraphy
Scales (that align with various themes):
- `scale_color_ipsum`: Discrete color & fill scales based on the ipsum
palette
- `scale_colour_ipsum`: Discrete color & fill scales based on the
ipsum palette
- `scale_fill_ipsum`: Discrete color & fill scales based on the ipsum
palette
- `scale_color_ft`: Discrete color & fill scales based on the FT
palette
- `scale_color_ipsum`: Discrete color & fill scales based on the ipsum
palette
- `scale_colour_ft`: Discrete color & fill scales based on the FT
palette
- `scale_colour_ipsum`: Discrete color & fill scales based on the
ipsum palette
- `scale_fill_ft`: Discrete color & fill scales based on the FT
palette
- `scale_x_comma`: X & Y scales with opinionated presets for percent &
comma label formats
- `scale_x_percent`: X & Y scales with opinionated presets for percent
- `scale_fill_ipsum`: Discrete color & fill scales based on the ipsum
palette
- `scale_x_comma`: X & Y scales with opinionated pre-sets for percent
& comma label formats
- `scale_y_comma`: X & Y scales with opinionated presets for percent &
comma label formats
- `scale_y_percent`: X & Y scales with opinionated presets for percent
- `scale_x_percent`: X & Y scales with opinionated pre-sets for
percent & comma label formats
- `scale_y_comma`: X & Y scales with opinionated pre-sets for percent
& comma label formats
- `scale_y_percent`: X & Y scales with opinionated pre-sets for
percent & comma label formats
Palettes/Named Colors:
@ -87,17 +75,10 @@ Palettes/Named Colors:
Fonts:
- `font_an`: Arial Narrow font name R variable aliases
- `font_es`: Econ Sans font name R variable aliases
- `font_es_bold`: Econ Sans font name R variable aliases
- `font_es_light`: Econ Sans font name R variable aliases
- `font_rc`: Roboto Condensed font name R variable aliases
- `font_rc_light`: Roboto Condensed font name R variable aliases
- `font_pub`: Public Sans font name R variable aliases
- `font_pub_bold`: Public Sans font name R variable aliases
- `font_pub_light`: Public Sans font name R variable aliases
- `font_pub_thin`: Public Sans font name R variable aliases
- `font_ps`: PlexSans font name R variable aliases
- `font_ps_light`: PlexSans font name R variable aliases
- `font_rc`: Roboto Condensed font name R variable aliases
- `font_rc_light`: Roboto Condensed font name R variable aliases
- `font_tw`: Titillium Web font name R variable aliases
- `font_tw_bold`: Titillium Web font name R variable aliases
- `font_tw_light`: Titillium Web font name R variable aliases
@ -113,8 +94,6 @@ Utilities:
- `ft_geom_defaults`: Change geom defaults from black to custom lights
for the FT theme
- `gg_check`: Spell check ggplot2 plot labels
- `import_econ_sans`: Import Econ Sans Condensed font for use in
charts
- `import_plex_sans`: Import IBM Plex Sans font for use in charts
- `import_roboto_condensed`: Import Roboto Condensed font for use in
charts
@ -127,24 +106,9 @@ Utilities:
### Installation
``` r
install.packages("hrbrthemes") # NOTE: CRAN version is 0.8.0
# or
install.packages("hrbrthemes", repos = c("https://cinc.rud.is", "https://cloud.r-project.org/"))
# or
remotes::install_git("https://git.rud.is/hrbrmstr/hrbrthemes.git")
# or
remotes::install_git("https://git.sr.ht/~hrbrmstr/hrbrthemes")
# or
remotes::install_gitlab("hrbrmstr/hrbrthemes")
# or
remotes::install_bitbucket("hrbrmstr/hrbrthemes")
# or
remotes::install_github("hrbrmstr/hrbrthemes")
devtools::install_github("hrbrmstr/hrbrthemes")
```
NOTE: To use the ‘remotes’ install options you will need to have the
[{remotes} package](https://github.com/r-lib/remotes) installed.
### Usage
``` r
@ -154,7 +118,7 @@ library(tidyverse)
# current verison
packageVersion("hrbrthemes")
## [1] '0.8.6'
## [1] '0.5.0'
```
### Base theme (Arial Narrow)
@ -169,7 +133,7 @@ ggplot(mtcars, aes(mpg, wt)) +
theme_ipsum()
```
<img src="man/figures/README-an-1.png" width="672" />
<img src="README_figs/README-unnamed-chunk-5-1.png" width="672" />
### Roboto Condensed
@ -183,7 +147,7 @@ ggplot(mtcars, aes(mpg, wt)) +
theme_ipsum_rc()
```
<img src="man/figures/README-rc-1.png" width="672" />
<img src="README_figs/README-unnamed-chunk-6-1.png" width="672" />
### New FT Theme\!
@ -197,7 +161,7 @@ ggplot(mtcars, aes(mpg, wt)) +
theme_ft_rc()
```
<img src="man/figures/README-ft-1.png" width="672" />
<img src="README_figs/README-ft-1.png" width="672" />
### IBM Plex Sans
@ -222,7 +186,7 @@ flush_ticks(gg)
## theme(axis.text.y=element_text(vjust=c(0, rep(0.5, 3), 1)))
```
<img src="man/figures/README-ps-1.png" width="960" />
<img src="README_figs/README-unnamed-chunk-7-1.png" width="960" />
### Titillium Web
@ -247,7 +211,7 @@ flush_ticks(gg)
## theme(axis.text.y=element_text(vjust=c(0, rep(0.5, 3), 1)))
```
<img src="man/figures/README-tw-1.png" width="960" />
<img src="README_figs/README-unnamed-chunk-8-1.png" width="960" />
### Scales (Color/Fill)
@ -262,7 +226,7 @@ ggplot(mtcars, aes(mpg, wt)) +
theme_ipsum_rc()
```
<img src="man/figures/README-sc-1.png" width="672" />
<img src="README_figs/README-unnamed-chunk-9-1.png" width="672" />
### Scales (Axis)
@ -279,7 +243,7 @@ count(mpg, class) %>%
theme_ipsum(grid="Y")
```
<img src="man/figures/README-ax1-1.png" width="672" />
<img src="README_figs/README-unnamed-chunk-10-1.png" width="672" />
``` r
ggplot(uspopage, aes(x=Year, y=Thousands, fill=AgeGroup)) +
@ -295,7 +259,7 @@ ggplot(uspopage, aes(x=Year, y=Thousands, fill=AgeGroup)) +
theme(legend.position="bottom")
```
<img src="man/figures/README-ax2-1.png" width="672" />
<img src="README_figs/README-unnamed-chunk-11-1.png" width="672" />
``` r
update_geom_font_defaults(font_rc_light)
@ -316,7 +280,7 @@ count(mpg, class) %>%
theme_ipsum_rc(grid="X")
```
<img src="man/figures/README-ax3-1.png" width="672" />
<img src="README_figs/README-unnamed-chunk-12-1.png" width="672" />
### Spellcheck ggplot2 labels
@ -337,18 +301,17 @@ gg_check(gg)
## Possible misspelled words in [caption]: (captien)
```
<img src="man/figures/README-sp-1.png" width="672" />
<img src="README_figs/README-unnamed-chunk-13-1.png" width="672" />
### hrbrthemes Metrics
| Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) |
| :--- | -------: | ---: | ---: | ---: | ----------: | ---: | -------: | ---: |
| R | 24 | 0.89 | 1724 | 0.80 | 327 | 0.72 | 908 | 0.84 |
| HTML | 1 | 0.04 | 297 | 0.14 | 32 | 0.07 | 2 | 0.00 |
| Rmd | 2 | 0.07 | 129 | 0.06 | 98 | 0.21 | 168 | 0.16 |
| Lang | \# Files | (%) | LoC | (%) | Blank lines | (%) | \# Lines | (%) |
| :--- | -------: | ---: | ---: | --: | ----------: | ---: | -------: | ---: |
| R | 20 | 0.91 | 1083 | 0.9 | 212 | 0.68 | 582 | 0.78 |
| Rmd | 2 | 0.09 | 124 | 0.1 | 99 | 0.32 | 162 | 0.22 |
### Code of Conduct
Please note that this project is released with a Contributor Code of
Conduct. 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-ft-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 158 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 95 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 78 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 74 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 206 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

BIN
README_files/figure-gfm/ft-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 78 KiB

BIN
README_files/figure-gfm/unnamed-chunk-10-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 62 KiB

BIN
README_files/figure-gfm/unnamed-chunk-2-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 79 KiB

BIN
README_files/figure-gfm/unnamed-chunk-3-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 76 KiB

BIN
README_files/figure-gfm/unnamed-chunk-4-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 212 KiB

BIN
README_files/figure-gfm/unnamed-chunk-5-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 213 KiB

BIN
README_files/figure-gfm/unnamed-chunk-6-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 84 KiB

BIN
README_files/figure-gfm/unnamed-chunk-7-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 KiB

BIN
README_files/figure-gfm/unnamed-chunk-8-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 155 KiB

BIN
README_files/figure-gfm/unnamed-chunk-9-1.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 95 KiB

BIN
README_files/figure-markdown_github/unnamed-chunk-10-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 61 KiB

BIN
README_files/figure-markdown_github/unnamed-chunk-10-2.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

BIN
README_files/figure-markdown_github/unnamed-chunk-4-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 76 KiB

BIN
README_files/figure-markdown_github/unnamed-chunk-5-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 75 KiB

BIN
README_files/figure-markdown_github/unnamed-chunk-6-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 83 KiB

BIN
README_files/figure-markdown_github/unnamed-chunk-7-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 77 KiB

BIN
README_files/figure-markdown_github/unnamed-chunk-8-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 129 KiB

BIN
README_files/figure-markdown_github/unnamed-chunk-9-1.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 92 KiB

20
cran-comments.md

@ -1,13 +1,23 @@
## Test environments
* local OS X install, R 3.6.3
* ubuntu 14.04 (on travis-ci), R 3.6.3
* local OS X install + travis-ci, R 3.5.0 & devel (Travis is currently failing
- if folks check - due to a missing CRAN mirror component in RStudio's CRAN
mirror for Travis)
* ubuntu 14.04 (on travis-ci), R oldrel, current, devel
* win-builder (devel and release)
* rhub::check_for_cran()
## R CMD check results
0 errors | 0 warnings | 0 notes
0 errors | 0 warnings | 0 notes%>% hrbrthemes exported operators
## Reverse dependencies
* This is an update
- [BAwiR, fontHind, fontMPlus, ggstatsplot, mlr] all OK
i think i fixed the named package link in the revdep.
---
- new fonts, a new white theme and a new dark theme
- fixed typos in documentation
- resubmitted after errors noted on https://win-builder.r-project.org/incoming_pretest/hrbrthemes_0.6.0_20190120_223916/Windows/00check.log
- re-re-submitted (gdtools in the right place now)

2
docs/CONDUCT.html

@ -135,7 +135,7 @@
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/LICENSE-text.html

@ -129,7 +129,7 @@ COPYRIGHT HOLDER: Bob Rudis
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/articles/index.html

@ -131,7 +131,7 @@
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

4
docs/articles/why_hrbrthemes.html

@ -83,7 +83,7 @@
<h1>Why hrbrthemes?</h1>
<h4 class="author">Bob Rudis</h4>
<h4 class="date">2019-02-07</h4>
<h4 class="date">2019-01-21</h4>
<small class="dont-index">Source: <a href="https://github.com/hrbrmstr/hrbrthemes/blob/master/vignettes/why_hrbrthemes.Rmd"><code>vignettes/why_hrbrthemes.Rmd</code></a></small>
<div class="hidden name"><code>why_hrbrthemes.Rmd</code></div>
@ -186,7 +186,7 @@
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/authors.html

@ -168,7 +168,7 @@
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

17
docs/index.html

@ -23,7 +23,7 @@
<![endif]-->
</head>
<body>
<div class="container template-home">
<div class="container template-article">
<header><div class="navbar navbar-default navbar-fixed-top" role="navigation">
<div class="container">
<div class="navbar-header">
@ -83,7 +83,11 @@
</header><div class="row">
<div class="contents col-md-9">
<div class="col-md-9 contents">
<div id="hrbrthemes-additional-themes-and-theme-components-for-ggplot2" class="section level2">
<h2 class="hasAnchor">
<a href="#hrbrthemes-additional-themes-and-theme-components-for-ggplot2" class="anchor"></a><code>hrbrthemes</code> : Additional Themes and Theme Components for ‘ggplot2’</h2>
@ -200,7 +204,7 @@
<a class="sourceLine" id="cb2-4" data-line-number="4"></a>
<a class="sourceLine" id="cb2-5" data-line-number="5"><span class="co"># current verison</span></a>
<a class="sourceLine" id="cb2-6" data-line-number="6"><span class="kw"><a href="https://www.rdocumentation.org/packages/utils/topics/packageDescription">packageVersion</a></span>(<span class="st">"hrbrthemes"</span>)</a>
<a class="sourceLine" id="cb2-7" data-line-number="7"><span class="co">## [1] '0.6.0'</span></a></code></pre></div>
<a class="sourceLine" id="cb2-7" data-line-number="7"><span class="co">## [1] '0.5.0'</span></a></code></pre></div>
</div>
<div id="base-theme-arial-narrow" class="section level3">
<h3 class="hasAnchor">
@ -409,7 +413,7 @@
</div>
</div>
<div class="col-md-3" id="sidebar">
<div class="col-md-3 hidden-xs hidden-sm" id="sidebar">
<div class="links">
<h2>Links</h2>
<ul class="list-unstyled">
@ -437,7 +441,8 @@
</ul>
</div>
</div>
</div>
</div>
@ -446,7 +451,7 @@
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/news/index.html

@ -222,7 +222,7 @@
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/pkgdown.css

@ -65,7 +65,7 @@ summary {
/* Typographic tweaking ---------------------------------*/
.contents h1.page-header {
.contents .page-header {
margin-top: calc(-60px + 1em);
}

9
docs/pkgdown.js

@ -25,6 +25,10 @@
for (var i = 0; i < links.length; i++) {
if (links[i].getAttribute("href") === "#")
continue;
// Ignore external links
if (links[i].host !== location.host)
continue;
var nav_path = paths(links[i].pathname);
var length = prefix_length(nav_path, cur_path);
@ -52,13 +56,14 @@
return(pieces);
}
// Returns -1 if not found
function prefix_length(needle, haystack) {
if (needle.length > haystack.length)
return(0);
return(-1);
// Special case for length-0 haystack, since for loop won't run
if (haystack.length === 0) {
return(needle.length === 0 ? 1 : 0);
return(needle.length === 0 ? 0 : -1);
}
for (var i = 0; i < haystack.length; i++) {

2
docs/pkgdown.yml

@ -1,5 +1,5 @@
pandoc: 2.3.1
pkgdown: 1.2.0
pkgdown: 1.3.0
pkgdown_sha: ~
articles:
why_hrbrthemes: why_hrbrthemes.html

2
docs/reference/ArialNarrow.html

@ -149,7 +149,7 @@
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/PlexSans.html

@ -160,7 +160,7 @@ Windows and will throw a warning if used in plots.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/RobotoCondensed.html

@ -160,7 +160,7 @@ Windows and will throw a warning if used in plots.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/TitilliumWeb.html

@ -166,7 +166,7 @@ Windows and will throw a warning if used in plots.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/flush_ticks.html

@ -189,7 +189,7 @@ take a while.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/ft_cols.html

@ -157,7 +157,7 @@
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/ft_geom_defaults.html

@ -143,7 +143,7 @@
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/ft_pal.html

@ -148,7 +148,7 @@
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/gg_check.html

@ -196,7 +196,7 @@ words.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/hrbrthemes-exports.html

@ -146,7 +146,7 @@ pipe operator with no additional library calls</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/hrbrthemes.html

@ -162,7 +162,7 @@ to register non-core fonts with the Windows graphics device.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/import_plex_sans.html

@ -161,7 +161,7 @@ other font you wish to use in other programs.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/import_roboto_condensed.html

@ -161,7 +161,7 @@ other font you wish to use in other programs.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/import_titillium_web.html

@ -161,7 +161,7 @@ other font you wish to use in other programs.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/index.html

@ -298,7 +298,7 @@
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

4
docs/reference/ipsum.html

@ -146,7 +146,7 @@
</tr>
<tr>
<th>fig_height</th>
<td><p>Default height (in inches) for figures</p></td>
<td><p>Default width (in inches) for figures</p></td>
</tr>
<tr>
<th>fig_retina</th>
@ -248,7 +248,7 @@ additional details.</p></td>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/ipsum_pal.html

@ -148,7 +148,7 @@
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/ipsum_pdf.html

@ -159,7 +159,7 @@
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/modern_geom_defaults.html

@ -143,7 +143,7 @@
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/scale_ft.html

@ -199,7 +199,7 @@ The default, <code>TRUE</code>, uses the levels that appear in the data;
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/scale_ipsum.html

@ -199,7 +199,7 @@ The default, <code>TRUE</code>, uses the levels that appear in the data;
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/scale_x_percent.html

@ -248,7 +248,7 @@ scales, "top" or "bottom" for horizontal scales</p></td>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/theme_ipsum.html

@ -281,7 +281,7 @@ to register non-core fonts with the Windows graphics device.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/theme_ipsum_ps.html

@ -273,7 +273,7 @@ to register non-core fonts with the Windows graphics device.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/theme_ipsum_rc.html

@ -304,7 +304,7 @@ than Arial Narrow and the fonts most folks use in ggplot2 charts.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/theme_ipsum_tw.html

@ -275,7 +275,7 @@ than Arial Narrow and the fonts most folks use in ggplot2 charts.</p>
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

2
docs/reference/update_geom_font_defaults.html

@ -154,7 +154,7 @@
</div>
<div class="pkgdown">
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.2.0.</p>
<p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.3.0.</p>
</div>
</footer>
</div>

110
inst/COPYRIGHTS

@ -2,106 +2,6 @@ All R source code files are released under the MIT license.
-----------------------------
Inter has the following license/copyright:
Copyright (c) 2016-2020 The Inter Project Authors.
"Inter" is a Reserved Font Name.
https://github.com/rsms/inter
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 AND 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.
-----------------------------
IBM Plex Sans font has the following license/copyright:
Copyright © 2017 IBM Corp. with Reserved Font Name "Plex"
@ -110,16 +10,6 @@ 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
-----------------------------
Public Sans font has the following license/copyright:
Copyright (c) 2015, Impallari Type (www.impallari.com)
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
-----------------------------------------------------------

BIN
inst/fonts/econ-sans/econsans-condensed-primary-subset-bd-it.ttf

Binary file not shown.

BIN
inst/fonts/econ-sans/econsans-condensed-primary-subset-bd.ttf

Binary file not shown.

BIN
inst/fonts/econ-sans/econsans-condensed-primary-subset-it.ttf

Binary file not shown.

BIN
inst/fonts/econ-sans/econsans-condensed-primary-subset-li-it.ttf

Binary file not shown.

BIN
inst/fonts/econ-sans/econsans-condensed-primary-subset-li.ttf

Binary file not shown.

BIN
inst/fonts/econ-sans/econsans-condensed-primary-subset-md-it.ttf

Binary file not shown.

BIN
inst/fonts/econ-sans/econsans-condensed-primary-subset-md.ttf

Binary file not shown.

Some files were not shown because too many files changed in this diff

Loading…
Cancel
Save