Browse Source

Added Titillium Web

tags/0.8.0
boB Rudis 6 years ago
parent
commit
80b8a2128d
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 5
      NAMESPACE
  2. 1
      NEWS.md
  3. 224
      R/titillium-web.R
  4. 32
      README.Rmd
  5. 57
      README.md
  6. BIN
      README_figs/README-unnamed-chunk-10-1.png
  7. BIN
      README_figs/README-unnamed-chunk-11-1.png
  8. BIN
      README_figs/README-unnamed-chunk-12-1.png
  9. BIN
      README_figs/README-unnamed-chunk-13-1.png
  10. BIN
      README_figs/README-unnamed-chunk-7-1.png
  11. BIN
      README_figs/README-unnamed-chunk-8-1.png
  12. BIN
      README_figs/README-unnamed-chunk-9-1.png
  13. BIN
      inst/fonts/titillium-web/TitilliumWeb-Bold.ttf
  14. BIN
      inst/fonts/titillium-web/TitilliumWeb-BoldItalic.ttf
  15. BIN
      inst/fonts/titillium-web/TitilliumWeb-Italic.ttf
  16. BIN
      inst/fonts/titillium-web/TitilliumWeb-Light.ttf
  17. BIN
      inst/fonts/titillium-web/TitilliumWeb-LightItalic.ttf
  18. BIN
      inst/fonts/titillium-web/TitilliumWeb-Regular.ttf
  19. 31
      man/TitilliumWeb.Rd
  20. 23
      man/import_titillium_web.Rd
  21. 99
      man/theme_ipsum_tw.Rd

5
NAMESPACE

@ -7,9 +7,13 @@ export(font_ps)
export(font_ps_light)
export(font_rc)
export(font_rc_light)
export(font_tw)
export(font_tw_bols)
export(font_tw_light)
export(gg_check)
export(import_plex_sans)
export(import_roboto_condensed)
export(import_titillium_web)
export(ipsum)
export(ipsum_pal)
export(ipsum_pdf)
@ -24,6 +28,7 @@ export(scale_y_percent)
export(theme_ipsum)
export(theme_ipsum_ps)
export(theme_ipsum_rc)
export(theme_ipsum_tw)
export(theme_modern_rc)
export(update_geom_font_defaults)
import(extrafont)

1
NEWS.md

@ -4,6 +4,7 @@
* `flush_ticks()` for easier alignment of x/y axis labels
* `ipsum_pdf` R Markdown format for using hrbrthemes in PDFs
* `theme_ipsum_tw()` (+ fonts) a Titillium Web-based theme
# hrbrthemes 0.3.2

224
R/titillium-web.R

@ -0,0 +1,224 @@
#' 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
#' 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
#' @examples \dontrun{
#' library(ggplot2)
#' library(dplyr)
#'
#' # seminal scatterplot
#' ggplot(mtcars, aes(mpg, wt)) +
#' geom_point() +
#' labs(x="Fuel effiiency (mpg)", y="Weight (tons)",
#' title="Seminal ggplot2 scatterplot example",
#' subtitle="A plot that is only useful for demonstration purposes",
#' caption="Brought to you by the letter 'g'") +
#' theme_ipsum_rc()
#'
#' # seminal bar chart
#'
#' # note: make this font_rc on Windows
#' update_geom_font_defaults(family=font_rc_light)
#'
#' count(mpg, class) %>%
#' ggplot(aes(class, n)) +
#' geom_col() +
#' geom_text(aes(label=n), nudge_y=3) +
#' labs(x="Fuel effiiency (mpg)", y="Weight (tons)",
#' title="Seminal ggplot2 bar chart example",
#' subtitle="A plot that is only useful for demonstration purposes",
#' caption="Brought to you by the letter 'g'") +
#' theme_ipsum_tw(grid="Y") +
#' theme(axis.text.y=element_blank())
#' }
theme_ipsum_tw <- function(
base_family="Titillium Web", base_size = 11.5,
plot_title_family=if (.Platform$OS.type == "windows") "Titillium Web" else "Titillium WebBold",
plot_title_size = 18,
plot_title_face="bold",
plot_title_margin = 10,
subtitle_family=if (.Platform$OS.type == "windows") "Titillium Web" else "Titillium WebLight",
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") "Titillium Web" else "Titillium WebLight",
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_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)
)
}
#' @rdname TitilliumWeb
#' @md
#' @title Titillium Web font name R variable aliases
#' @description `font_tw` == "`Titillium Web`"
#' @format length 1 character vector
#' @export
font_tw <- "Titillium Web"
#' @rdname TitilliumWeb
#' @md
#' @note `font_tw_light` (a.k.a. "`Titillium WebBold`") is not available on
#' Windows and will throw a warning if used in plots.
#' @description `font_tw_light` == "`Titillium WebBold`"
#' @export
font_tw_bols <- "Titillium WebBold"
#' @rdname TitilliumWeb
#' @md
#' @note `font_tw_light` (a.k.a. "`Titillium WebLight`") is not available on
#' Windows and will throw a warning if used in plots.
#' @description `font_tw_light` == "`Titillium WebLight`"
#' @export
font_tw_light <- "Titillium WebLight"

32
README.Rmd

@ -25,8 +25,9 @@ The following functions are implemented/objects are exported:
Core themes & scales:
- `theme_ipsum`: Arial Narrow-based theme
- `theme_ipsum_rc`: Roboto Condensed-based theme
- `theme_ipsum_ps`: IBM Plex Sans-based theme
- `theme_ipsum_rc`: Roboto Condensed-based theme
- `theme_ipsum_tw`: Titillium Web-based theme
- `scale_x_comma` / `scale_y_comma`: Comma format for axis text and better `expand` defaults (you need to set limits)
- `scale_x_percent` / `scale_y_percent`: Percent format for axis text and `expand=c(0,0)` (you need to set limits)
- `scale_color_ipsum` / `scale_fill_ipsum` / `ipsum_pal`: A muted discrete color palette with 9 colors
@ -45,10 +46,14 @@ R Markdown:
The following global variables are now in your namespace:
- `font_an`: a short global alias for "`Arial Narrow`"
- `font_rc`: a short global alias for "`Roboto Condensed`"
- `font_rc_light`: a short global alias for "`Roboto Condensed Light`"
- `font_ps`: a short global alias for "`IBMPlexSans`"
- `font_ps_light`: a short global alias for "`IBMPlexSans-Light`"
- `font_rc`: a short global alias for "`Roboto Condensed`"
- `font_rc_light`: a short global alias for "`Roboto Condensed Light`"
- `font_tw`: a short global alias for "`Titillium Web`"
- `font_tw_bold`: a short global alias for "`Titillium WebBold`" (note the lack of a space after `Web`)
- `font_tw_light`: a short global alias for "`Titillium WebLight`" (note the lack of a space after `Web`)
### Installation
@ -116,6 +121,27 @@ ggplot(mpg, aes(displ, hwy)) +
flush_ticks(gg)
```
### IBM Plex Sans
```{r fig.width=10, fig.height=7, fig.retina=2}
ggplot(mpg, aes(displ, hwy)) +
geom_jitter(aes(color=class, fill=class), size=3, shape=21, alpha=1/2) +
scale_x_continuous(expand=c(0,0), limits=c(1, 8), breaks=1:8) +
scale_y_continuous(expand=c(0,0), limits=c(10, 50)) +
scale_color_ipsum() +
scale_fill_ipsum() +
facet_wrap(~class, scales="free") +
labs(
title="Titillium Web",
subtitle="This is a subtitle to see the how it looks in Titillium Web",
caption="Source: hrbrthemes & Google"
) +
theme_ipsum_tw(grid="XY", axis="xy") +
theme(legend.position="none") -> gg
flush_ticks(gg)
```
### Scales (Color/Fill)
```{r fig.retina=2}

57
README.md

@ -31,8 +31,9 @@ The following functions are implemented/objects are exported:
Core themes & scales:
- `theme_ipsum`: Arial Narrow-based theme
- `theme_ipsum_rc`: Roboto Condensed-based theme
- `theme_ipsum_ps`: IBM Plex Sans-based theme
- `theme_ipsum_rc`: Roboto Condensed-based theme
- `theme_ipsum_tw`: Titillium Web-based theme
- `scale_x_comma` / `scale_y_comma`: Comma format for axis text and
better `expand` defaults (you need to set limits)
- `scale_x_percent` / `scale_y_percent`: Percent format for axis text
@ -55,10 +56,15 @@ R Markdown:
The following global variables are now in your namespace:
- `font_an`: a short global alias for “`Arial Narrow`”
- `font_rc`: a short global alias for “`Roboto Condensed`”
- `font_rc_light`: a short global alias for “`Roboto Condensed Light`”
- `font_ps`: a short global alias for “`IBMPlexSans`”
- `font_ps_light`: a short global alias for “`IBMPlexSans-Light`”
- `font_rc`: a short global alias for “`Roboto Condensed`”
- `font_rc_light`: a short global alias for “`Roboto Condensed Light`”
- `font_tw`: a short global alias for “`Titillium Web`”
- `font_tw_bold`: a short global alias for “`Titillium WebBold`” (note
the lack of a space after `Web`)
- `font_tw_light`: a short global alias for “`Titillium WebLight`”
(note the lack of a space after `Web`)
### Installation
@ -131,6 +137,31 @@ flush_ticks(gg)
<img src="README_figs/README-unnamed-chunk-7-1.png" width="960" />
### IBM Plex Sans
``` r
ggplot(mpg, aes(displ, hwy)) +
geom_jitter(aes(color=class, fill=class), size=3, shape=21, alpha=1/2) +
scale_x_continuous(expand=c(0,0), limits=c(1, 8), breaks=1:8) +
scale_y_continuous(expand=c(0,0), limits=c(10, 50)) +
scale_color_ipsum() +
scale_fill_ipsum() +
facet_wrap(~class, scales="free") +
labs(
title="Titillium Web",
subtitle="This is a subtitle to see the how it looks in Titillium Web",
caption="Source: hrbrthemes & Google"
) +
theme_ipsum_tw(grid="XY", axis="xy") +
theme(legend.position="none") -> gg
flush_ticks(gg)
## theme(axis.text.x=element_text(hjust=c(0, rep(0.5, 6), 1))) +
## theme(axis.text.y=element_text(vjust=c(0, rep(0.5, 3), 1)))
```
<img src="README_figs/README-unnamed-chunk-8-1.png" width="960" />
### Scales (Color/Fill)
``` r
@ -144,7 +175,7 @@ ggplot(mtcars, aes(mpg, wt)) +
theme_ipsum_rc()
```
<img src="README_figs/README-unnamed-chunk-8-1.png" width="672" />
<img src="README_figs/README-unnamed-chunk-9-1.png" width="672" />
### Scales (Axis)
@ -161,7 +192,7 @@ count(mpg, class) %>%
theme_ipsum(grid="Y")
```
<img src="README_figs/README-unnamed-chunk-9-1.png" width="672" />
<img src="README_figs/README-unnamed-chunk-10-1.png" width="672" />
``` r
ggplot(uspopage, aes(x=Year, y=Thousands, fill=AgeGroup)) +
@ -177,7 +208,7 @@ ggplot(uspopage, aes(x=Year, y=Thousands, fill=AgeGroup)) +
theme(legend.position="bottom")
```
<img src="README_figs/README-unnamed-chunk-10-1.png" width="672" />
<img src="README_figs/README-unnamed-chunk-11-1.png" width="672" />
``` r
update_geom_font_defaults(font_rc_light)
@ -198,7 +229,7 @@ count(mpg, class) %>%
theme_ipsum_rc(grid="X")
```
<img src="README_figs/README-unnamed-chunk-11-1.png" width="672" />
<img src="README_figs/README-unnamed-chunk-12-1.png" width="672" />
### Spellcheck ggplot2 labels
@ -219,7 +250,7 @@ gg_check(gg)
## Possible misspelled words in [caption]: (captien)
```
<img src="README_figs/README-unnamed-chunk-12-1.png" width="672" />
<img src="README_figs/README-unnamed-chunk-13-1.png" width="672" />
### Test Results
@ -227,7 +258,7 @@ gg_check(gg)
library(hrbrthemes)
date()
## [1] "Thu Dec 21 15:56:49 2017"
## [1] "Tue Jan 9 15:44:53 2018"
devtools::test()
## ✔ | OK F W S | Context
@ -243,17 +274,17 @@ devtools::test()
⠧ | 8 | basic functionality
⠇ | 9 | basic functionality
⠏ | 10 | basic functionality
✔ | 10 | basic functionality [2.1 s]
✔ | 10 | basic functionality [2.0 s]
##
⠏ | 0 | themes
##
⠋ | 1 | themes
##
⠙ | 2 | themes
✔ | 2 | themes [0.8 s]
✔ | 2 | themes [0.7 s]
##
## ══ Results ═════════════════════════════════════════════════════════════════════════════════════════════════════════════════
## Duration: 3.0 s
## ══ Results ════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════════
## Duration: 2.8 s
##
## OK: 12
## Failed: 0

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 132 KiB

After

Width:  |  Height:  |  Size: 82 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 94 KiB

After

Width:  |  Height:  |  Size: 132 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 63 KiB

After

Width:  |  Height:  |  Size: 94 KiB

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

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 215 KiB

After

Width:  |  Height:  |  Size: 214 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 85 KiB

After

Width:  |  Height:  |  Size: 216 KiB

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

Binary file not shown.

Before

Width:  |  Height:  |  Size: 82 KiB

After

Width:  |  Height:  |  Size: 85 KiB

BIN
inst/fonts/titillium-web/TitilliumWeb-Bold.ttf

Binary file not shown.

BIN
inst/fonts/titillium-web/TitilliumWeb-BoldItalic.ttf

Binary file not shown.

BIN
inst/fonts/titillium-web/TitilliumWeb-Italic.ttf

Binary file not shown.

BIN
inst/fonts/titillium-web/TitilliumWeb-Light.ttf

Binary file not shown.

BIN
inst/fonts/titillium-web/TitilliumWeb-LightItalic.ttf

Binary file not shown.

BIN
inst/fonts/titillium-web/TitilliumWeb-Regular.ttf

Binary file not shown.

31
man/TitilliumWeb.Rd

@ -0,0 +1,31 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/titillium-web.R
\docType{data}
\name{font_tw}
\alias{font_tw}
\alias{font_tw_bols}
\alias{font_tw_light}
\title{Titillium Web font name R variable aliases}
\format{length 1 character vector}
\usage{
font_tw
font_tw_bols
font_tw_light
}
\description{
\code{font_tw} == "\code{Titillium Web}"
\code{font_tw_light} == "\code{Titillium WebBold}"
\code{font_tw_light} == "\code{Titillium WebLight}"
}
\note{
\code{font_tw_light} (a.k.a. "\code{Titillium WebBold}") is not available on
Windows and will throw a warning if used in plots.
\code{font_tw_light} (a.k.a. "\code{Titillium WebLight}") is not available on
Windows and will throw a warning if used in plots.
}
\keyword{datasets}

23
man/import_titillium_web.Rd

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

99
man/theme_ipsum_tw.Rd

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