Browse Source

added public sans

tags/0.8.0
boB Rudis 5 years ago
parent
commit
b45e82fbf7
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
  1. 10
      DESCRIPTION
  2. 6
      NAMESPACE
  3. 228
      R/public-sans.R
  4. 5
      README.Rmd
  5. 6
      README.md
  6. 10
      inst/COPYRIGHTS
  7. BIN
      inst/fonts/public-sans/PublicSans-Black.ttf
  8. BIN
      inst/fonts/public-sans/PublicSans-BlackItalic.ttf
  9. BIN
      inst/fonts/public-sans/PublicSans-Bold.ttf
  10. BIN
      inst/fonts/public-sans/PublicSans-BoldItalic.ttf
  11. BIN
      inst/fonts/public-sans/PublicSans-ExtraBold.ttf
  12. BIN
      inst/fonts/public-sans/PublicSans-ExtraBoldItalic.ttf
  13. BIN
      inst/fonts/public-sans/PublicSans-ExtraLight.ttf
  14. BIN
      inst/fonts/public-sans/PublicSans-ExtraLightItalic.ttf
  15. BIN
      inst/fonts/public-sans/PublicSans-Italic.ttf
  16. BIN
      inst/fonts/public-sans/PublicSans-Light.ttf
  17. BIN
      inst/fonts/public-sans/PublicSans-LightItalic.ttf
  18. BIN
      inst/fonts/public-sans/PublicSans-Medium.ttf
  19. BIN
      inst/fonts/public-sans/PublicSans-MediumItalic.ttf
  20. BIN
      inst/fonts/public-sans/PublicSans-Regular.ttf
  21. BIN
      inst/fonts/public-sans/PublicSans-SemiBold.ttf
  22. BIN
      inst/fonts/public-sans/PublicSans-SemiBoldItalic.ttf
  23. BIN
      inst/fonts/public-sans/PublicSans-Thin.ttf
  24. BIN
      inst/fonts/public-sans/PublicSans-ThinItalic.ttf
  25. 33
      man/PublicSans.Rd
  26. 24
      man/import_public_sans.Rd
  27. 100
      man/theme_ipsum_pub.Rd

10
DESCRIPTION

@ -1,8 +1,8 @@
Package: hrbrthemes
Type: Package
Title: Additional Themes, Theme Components and Utilities for 'ggplot2'
Version: 0.6.0
Date: 2019-01-20
Version: 0.7.0
Date: 2019-04-09
Authors@R: c(
person("Bob", "Rudis", email = "bob@rud.is", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-5670-2640")),
@ -14,6 +14,7 @@ Authors@R: c(
person("Google", comment = "Roboto Condensed & Titillium Web Fonts",
role = c("cph")),
person("IBM", comment = "Plex 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")),
@ -23,8 +24,9 @@ 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>
and 'Titillium Web' <https://fonts.google.com/specimen/Titillium+Web> fonts
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
are also included to support their respective typography-oriented themes.
URL: http://github.com/hrbrmstr/hrbrthemes
BugReports: https://github.com/hrbrmstr/hrbrthemes/issues

6
NAMESPACE

@ -5,6 +5,10 @@ export(flush_ticks)
export(font_an)
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_tw)
@ -16,6 +20,7 @@ export(ft_pal)
export(ft_text_col)
export(gg_check)
export(import_plex_sans)
export(import_public_sans)
export(import_roboto_condensed)
export(import_titillium_web)
export(ipsum)
@ -35,6 +40,7 @@ export(scale_y_percent)
export(theme_ft_rc)
export(theme_ipsum)
export(theme_ipsum_ps)
export(theme_ipsum_pub)
export(theme_ipsum_rc)
export(theme_ipsum_tw)
export(theme_modern_rc)

228
R/public-sans.R

@ -0,0 +1,228 @@
#' 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 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_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 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_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"

5
README.Rmd

@ -27,6 +27,7 @@ Themes:
- `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_pub`: 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
@ -54,6 +55,10 @@ Palettes/Named Colors:
Fonts:
- `font_an`: Arial Narrow 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

6
README.md

@ -35,6 +35,8 @@ Themes:
defaults and an emphasis on typography
- `theme_ipsum_ps`: A precise & pristine ggplot2 theme with
opinionated defaults and an emphasis on typoghraphy
- `theme_ipsum_pub`: 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
@ -77,6 +79,10 @@ Fonts:
- `font_an`: Arial Narrow font name R variable aliases
- `font_ps`: PlexSans font name R variable aliases
- `font_ps_light`: PlexSans 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_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

10
inst/COPYRIGHTS

@ -10,6 +10,16 @@ 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/public-sans/PublicSans-Black.ttf

Binary file not shown.

BIN
inst/fonts/public-sans/PublicSans-BlackItalic.ttf

Binary file not shown.

BIN
inst/fonts/public-sans/PublicSans-Bold.ttf

Binary file not shown.

BIN
inst/fonts/public-sans/PublicSans-BoldItalic.ttf

Binary file not shown.

BIN
inst/fonts/public-sans/PublicSans-ExtraBold.ttf

Binary file not shown.

BIN
inst/fonts/public-sans/PublicSans-ExtraBoldItalic.ttf

Binary file not shown.

BIN
inst/fonts/public-sans/PublicSans-ExtraLight.ttf

Binary file not shown.

BIN
inst/fonts/public-sans/PublicSans-ExtraLightItalic.ttf

Binary file not shown.

BIN
inst/fonts/public-sans/PublicSans-Italic.ttf

Binary file not shown.

BIN
inst/fonts/public-sans/PublicSans-Light.ttf

Binary file not shown.

BIN
inst/fonts/public-sans/PublicSans-LightItalic.ttf

Binary file not shown.

BIN
inst/fonts/public-sans/PublicSans-Medium.ttf

Binary file not shown.

BIN
inst/fonts/public-sans/PublicSans-MediumItalic.ttf

Binary file not shown.

BIN
inst/fonts/public-sans/PublicSans-Regular.ttf

Binary file not shown.

BIN
inst/fonts/public-sans/PublicSans-SemiBold.ttf

Binary file not shown.

BIN
inst/fonts/public-sans/PublicSans-SemiBoldItalic.ttf

Binary file not shown.

BIN
inst/fonts/public-sans/PublicSans-Thin.ttf

Binary file not shown.

BIN
inst/fonts/public-sans/PublicSans-ThinItalic.ttf

Binary file not shown.

33
man/PublicSans.Rd

@ -0,0 +1,33 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/public-sans.R
\docType{data}
\name{font_pub}
\alias{font_pub}
\alias{font_pub_bold}
\alias{font_pub_light}
\alias{font_pub_thin}
\title{Public Sans font name R variable aliases}
\format{length 1 character vector}
\usage{
font_pub
font_pub_bold
font_pub_light
font_pub_thin
}
\description{
\code{font_pub} == "\code{Public Sans}"
\code{font_pub_bold} == "\code{Public Sans Bold}"
\code{font_pub_light} == "\code{Public Sans Light}"
\code{font_pub_thin} == "\code{Public Sans Thin}"
}
\note{
\code{font_pub_bold} (a.k.a. "\code{Public Sans Bold}") is not available on
Windows and will throw a warning if used in plots.
}
\keyword{datasets}

24
man/import_public_sans.Rd

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

100
man/theme_ipsum_pub.Rd

@ -0,0 +1,100 @@
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/public-sans.R
\name{theme_ipsum_pub}
\alias{theme_ipsum_pub}
\title{A precise & pristine \link{ggplot2} theme with opinionated defaults and an emphasis on typoghraphy}
\usage{
theme_ipsum_pub(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)
}
\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_public_sans} first and also install the fonts on your
system before trying to use this theme.
}
\details{
There is an option \code{hrbrthemes.loadfonts} which -- if set to \code{TRUE} -- will
call \code{extrafont::loadfonts()} to register non-core fonts with R PDF & PostScript
devices. If you are running under Windows, the package calls the same function
to register non-core fonts with the Windows graphics device.
}
\section{Why Public Sans?}{
See \href{https://github.com/uswds/public-sans#design-principles}{the design principles}.
}
\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_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 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_pub(grid="Y") +
theme(axis.text.y=element_blank())
}
}
Loading…
Cancel
Save