Przeglądaj źródła

More rcmd check fixes

* fix style of ggplot2, xaringan pkg refs
* fix name of theme_xaringan_restore_defaults()
tags/v0.3.0
Garrick Aden-Buie 6 lat temu
rodzic
commit
adc43779f9
7 zmienionych plików z 49 dodań i 46 usunięć
  1. +1
    -1
      NAMESPACE
  2. +20
    -20
      R/ggplot2.R
  3. +4
    -6
      man/scale_xaringan.Rd
  4. +5
    -5
      man/theme_xaringan.Rd
  5. +4
    -4
      man/theme_xaringan_base.Rd
  6. +5
    -5
      man/theme_xaringan_inverse.Rd
  7. +10
    -5
      man/theme_xaringan_set_defaults.Rd

+ 1
- 1
NAMESPACE Wyświetl plik

export(theme_xaringan_base) export(theme_xaringan_base)
export(theme_xaringan_get_value) export(theme_xaringan_get_value)
export(theme_xaringan_inverse) export(theme_xaringan_inverse)
export(theme_xaringan_restore_defaults)
export(theme_xaringan_set_defaults) export(theme_xaringan_set_defaults)
export(write_extra_css) export(write_extra_css)
export(write_xaringan_theme) export(write_xaringan_theme)
export(xaringan_theme_restore_defaults)
importFrom(grDevices,col2rgb) importFrom(grDevices,col2rgb)
importFrom(grDevices,hsv) importFrom(grDevices,hsv)
importFrom(grDevices,rgb) importFrom(grDevices,rgb)

+ 20
- 20
R/ggplot2.R Wyświetl plik

#' #'
#' **Lifecycle:** [Experimental](https://www.tidyverse.org/lifecycle/#experimental). #' **Lifecycle:** [Experimental](https://www.tidyverse.org/lifecycle/#experimental).
#' #'
#' Creates [ggplot2] themes to match the xaringanthemer theme used in the
#' [xaringan] slides that seamlessly matches the "normal" slide colors and
#' Creates \pkg{ggplot2} themes to match the xaringanthemer theme used in the
#' \pkg{xaringan} slides that seamlessly matches the "normal" slide colors and
#' styles. #' styles.
#' #'
#' @param text_color Color for text and foreground, inherits from `text_color` #' @param text_color Color for text and foreground, inherits from `text_color`
#' #'
#' **Lifecycle:** [Experimental](https://www.tidyverse.org/lifecycle/#experimental). #' **Lifecycle:** [Experimental](https://www.tidyverse.org/lifecycle/#experimental).
#' #'
#' A [ggplot2] xaringanthemer plot theme to seamlessly match the "inverse"
#' [xaringan] slide colors and styles as styled by [xaringanthemer].
#' A \pkg{ggplot2} xaringanthemer plot theme to seamlessly match the "inverse"
#' \pkg{xaringan} slide colors and styles as styled by [xaringanthemer].
#' #'
#' @param text_color Color for text and foreground, inherits from `text_color` #' @param text_color Color for text and foreground, inherits from `text_color`
#' @param background_color Color for background, inherits from #' @param background_color Color for background, inherits from
#' #'
#' **Lifecycle:** [Experimental](https://www.tidyverse.org/lifecycle/#experimental). #' **Lifecycle:** [Experimental](https://www.tidyverse.org/lifecycle/#experimental).
#' #'
#' Provides a base plot theme for [ggplot2] to match the [xaringan] slide theme
#' Provides a base plot theme for \pkg{ggplot2} to match the \pkg{xaringan} slide theme
#' created by [xaringanthemer]. The theme is designed to create a general plot #' created by [xaringanthemer]. The theme is designed to create a general plot
#' style from two colors, a `background_color` and a `text_color` (or foreground #' style from two colors, a `background_color` and a `text_color` (or foreground
#' color). Also accepts an `accent_color` and an `accent_secondary_color` that are #' color). Also accepts an `accent_color` and an `accent_secondary_color` that are
#' @param accent_color Color for titles and accents, inherits from #' @param accent_color Color for titles and accents, inherits from
#' `header_color` or `text_color`. Used for the `title` base setting in #' `header_color` or `text_color`. Used for the `title` base setting in
#' [ggplot2::theme()], and additionally for setting the `color` or `fill` of #' [ggplot2::theme()], and additionally for setting the `color` or `fill` of
#' [ggplot2] geom defaults.
#' \pkg{ggplot2} geom defaults.
#' @param accent_secondary_color Color for secondary accents, inherits from #' @param accent_secondary_color Color for secondary accents, inherits from
#' `text_bold_color` or `accent_color`. Used only when setting [ggplot2] geom
#' `text_bold_color` or `accent_color`. Used only when setting \pkg{ggplot2} geom
#' defaults. #' defaults.
#' @param set_ggplot_defaults Should defaults be set for [ggplot2] _geoms_?
#' @param set_ggplot_defaults Should defaults be set for \pkg{ggplot2} _geoms_?
#' Defaults to TRUE. To restore ggplot's defaults, or the previously set geom #' Defaults to TRUE. To restore ggplot's defaults, or the previously set geom
#' defaults, see [theme_xaringan_restore_defaults()]. #' defaults, see [theme_xaringan_restore_defaults()].
#' @param text_font Font to use for text elements, passed to #' @param text_font Font to use for text elements, passed to
#' #'
#' **Lifecycle:** [Experimental](https://www.tidyverse.org/lifecycle/#experimental). #' **Lifecycle:** [Experimental](https://www.tidyverse.org/lifecycle/#experimental).
#' #'
#' Set [ggplot2] _geom_ defaults to match [theme_xaringan()] with
#' Set \pkg{ggplot2} _geom_ defaults to match [theme_xaringan()] with
#' `theme_xaringan_set_defaults()` and restore the standard or previously-set #' `theme_xaringan_set_defaults()` and restore the standard or previously-set
#' defaults with `theme_xaringan_restore_defaults()`. By default, #' defaults with `theme_xaringan_restore_defaults()`. By default,
#' `theme_xaringan_set_defaults()` is run with [theme_xaringan()] or #' `theme_xaringan_set_defaults()` is run with [theme_xaringan()] or
#' #'
#' @family xaringanthemer ggplot2 themes #' @family xaringanthemer ggplot2 themes
#' @inheritParams theme_xaringan #' @inheritParams theme_xaringan
#' @inheritParams theme_xaringan_base
#' @return Invisibly returns a list of the current ggplot2 geom defaults #' @return Invisibly returns a list of the current ggplot2 geom defaults
#' @export #' @export
theme_xaringan_set_defaults <- function( theme_xaringan_set_defaults <- function(
background_color = NULL, background_color = NULL,
accent_color = text_color, accent_color = text_color,
accent_secondary_color = accent_color, accent_secondary_color = accent_color,
text_family = NULL
text_font = NULL
) { ) {
requires_package("ggplot2") requires_package("ggplot2")


color = accent_secondary_color), color = accent_secondary_color),
"spoke" = list(color = text_color), "spoke" = list(color = text_color),
"label" = list(color = text_color, "label" = list(color = text_color,
family = text_family %||% get_theme_font("text")),
family = text_font %||% get_theme_font("text")),
"text" = list(color = text_color, "text" = list(color = text_color,
family = text_family %||% get_theme_font("text")),
family = text_font %||% get_theme_font("text")),
"rect" = list(fill = text_color), "rect" = list(fill = text_color),
"tile" = list(fill = text_color), "tile" = list(fill = text_color),
"violin" = list(fill = text_color), "violin" = list(fill = text_color),
invisible(previous_defaults) invisible(previous_defaults)
} }


#' @describeIn theme_xaringan_set_defaults Restore previous or standard [ggplot2] _geom_ defaults.
#' @inheritParams theme_xaringan
#' @describeIn theme_xaringan_set_defaults Restore previous or standard
#' \pkg{ggplot2} _geom_ defaults.
#' @return Invisibly returns a list of the current ggplot2 geom defaults #' @return Invisibly returns a list of the current ggplot2 geom defaults
#' @export #' @export
xaringan_theme_restore_defaults <- function() {
theme_xaringan_restore_defaults <- function() {
requires_package("ggplot2") requires_package("ggplot2")
requires_xaringanthemer_env() requires_xaringanthemer_env()


#' Color and fill single-color scales for discrete and continuous values, #' Color and fill single-color scales for discrete and continuous values,
#' created using the primary accent color of the xaringanthemer styles. #' created using the primary accent color of the xaringanthemer styles.
#' #'
#' @param ... Arguments passed on to the appropriate scale function, one of
#' [colorspace::scale_color_discrete_sequential],
#' @param ... Arguments passed on to either the \pkg{colorspace} scale
#' functions — one of [colorspace::scale_color_discrete_sequential],
#' [colorspace::scale_color_continuous_sequential], #' [colorspace::scale_color_continuous_sequential],
#' [colorspace::scale_fill_discrete_sequential], or #' [colorspace::scale_fill_discrete_sequential], or
#' [colorspace::scale_fill_continuous_sequential].
#' [colorspace::scale_fill_continuous_sequential] — or to
#' [ggplot2::continuous_scale] or [ggplot2::discrete_scale].
#' @param color A color value, in hex, to override the default color. Otherwise, #' @param color A color value, in hex, to override the default color. Otherwise,
#' the primary color of the resulting scale is chosen from the xaringanthemer #' the primary color of the resulting scale is chosen from the xaringanthemer
#' slide styles. #' slide styles.
#' @param direction Direction of the discrete scale. Use values less than 0 to #' @param direction Direction of the discrete scale. Use values less than 0 to
#' reverse the direction, e.g. `direction = -1`. #' reverse the direction, e.g. `direction = -1`.
#' @inheritParams colorspace::scale_color_continuous_sequential #' @inheritParams colorspace::scale_color_continuous_sequential
#' @param ... Additional arguments passed to [ggplot2::continuous_scale()] or
#' [ggplot2:discrete_scale()].
#' @param aes_type The type of aesthetic to which the scale is being applied. #' @param aes_type The type of aesthetic to which the scale is being applied.
#' One of "color", "colour", or "fill". #' One of "color", "colour", or "fill".
#' @name scale_xaringan #' @name scale_xaringan

+ 4
- 6
man/scale_xaringan.Rd Wyświetl plik

\item{aes_type}{The type of aesthetic to which the scale is being applied. \item{aes_type}{The type of aesthetic to which the scale is being applied.
One of "color", "colour", or "fill".} One of "color", "colour", or "fill".}


\item{...}{Arguments passed on to the appropriate scale function, one of
\link[colorspace:scale_color_discrete_sequential]{colorspace::scale_color_discrete_sequential},
\item{...}{Arguments passed on to either the \pkg{colorspace} scale
functions — one of \link[colorspace:scale_color_discrete_sequential]{colorspace::scale_color_discrete_sequential},
\link[colorspace:scale_color_continuous_sequential]{colorspace::scale_color_continuous_sequential}, \link[colorspace:scale_color_continuous_sequential]{colorspace::scale_color_continuous_sequential},
\link[colorspace:scale_fill_discrete_sequential]{colorspace::scale_fill_discrete_sequential}, or \link[colorspace:scale_fill_discrete_sequential]{colorspace::scale_fill_discrete_sequential}, or
\link[colorspace:scale_fill_continuous_sequential]{colorspace::scale_fill_continuous_sequential}.}
\link[colorspace:scale_fill_continuous_sequential]{colorspace::scale_fill_continuous_sequential} — or to
\link[ggplot2:continuous_scale]{ggplot2::continuous_scale} or \link[ggplot2:discrete_scale]{ggplot2::discrete_scale}.}


\item{color}{A color value, in hex, to override the default color. Otherwise, \item{color}{A color value, in hex, to override the default color. Otherwise,
the primary color of the resulting scale is chosen from the xaringanthemer the primary color of the resulting scale is chosen from the xaringanthemer
\item{begin}{Number in the range of \code{[0, 1]} indicating to which point in the color scale the smallest data value should be mapped.} \item{begin}{Number in the range of \code{[0, 1]} indicating to which point in the color scale the smallest data value should be mapped.}


\item{end}{Number in the range of \code{[0, 1]} indicating to which point in the color scale the largest data value should be mapped.} \item{end}{Number in the range of \code{[0, 1]} indicating to which point in the color scale the largest data value should be mapped.}

\item{...}{Additional arguments passed to \code{\link[ggplot2:continuous_scale]{ggplot2::continuous_scale()}} or
\code{\link[=ggplot2:discrete_scale]{ggplot2:discrete_scale()}}.}
} }
\description{ \description{
\strong{Lifecycle:} \href{https://www.tidyverse.org/lifecycle/#experimental}{Experimental}. \strong{Lifecycle:} \href{https://www.tidyverse.org/lifecycle/#experimental}{Experimental}.

+ 5
- 5
man/theme_xaringan.Rd Wyświetl plik

\item{accent_color}{Color for titles and accents, inherits from \item{accent_color}{Color for titles and accents, inherits from
\code{header_color} or \code{text_color}. Used for the \code{title} base setting in \code{header_color} or \code{text_color}. Used for the \code{title} base setting in
\code{\link[ggplot2:theme]{ggplot2::theme()}}, and additionally for setting the \code{color} or \code{fill} of \code{\link[ggplot2:theme]{ggplot2::theme()}}, and additionally for setting the \code{color} or \code{fill} of
\link{ggplot2} geom defaults.}
\pkg{ggplot2} geom defaults.}
\item{accent_secondary_color}{Color for secondary accents, inherits from \item{accent_secondary_color}{Color for secondary accents, inherits from
\code{text_bold_color} or \code{accent_color}. Used only when setting \link{ggplot2} geom
\code{text_bold_color} or \code{accent_color}. Used only when setting \pkg{ggplot2} geom
defaults.} defaults.}
\item{set_ggplot_defaults}{Should defaults be set for \link{ggplot2} \emph{geoms}?
\item{set_ggplot_defaults}{Should defaults be set for \pkg{ggplot2} \emph{geoms}?
Defaults to TRUE. To restore ggplot's defaults, or the previously set geom Defaults to TRUE. To restore ggplot's defaults, or the previously set geom
defaults, see \code{\link[=theme_xaringan_restore_defaults]{theme_xaringan_restore_defaults()}}.} defaults, see \code{\link[=theme_xaringan_restore_defaults]{theme_xaringan_restore_defaults()}}.}
\item{text_font}{Font to use for text elements, passed to \item{text_font}{Font to use for text elements, passed to
\description{ \description{
\strong{Lifecycle:} \href{https://www.tidyverse.org/lifecycle/#experimental}{Experimental}. \strong{Lifecycle:} \href{https://www.tidyverse.org/lifecycle/#experimental}{Experimental}.


Creates \link{ggplot2} themes to match the xaringanthemer theme used in the
\link{xaringan} slides that seamlessly matches the "normal" slide colors and
Creates \pkg{ggplot2} themes to match the xaringanthemer theme used in the
\pkg{xaringan} slides that seamlessly matches the "normal" slide colors and
styles. styles.
} }
\examples{ \examples{

+ 4
- 4
man/theme_xaringan_base.Rd Wyświetl plik



\item{...}{Ignored} \item{...}{Ignored}


\item{set_ggplot_defaults}{Should defaults be set for \link{ggplot2} \emph{geoms}?
\item{set_ggplot_defaults}{Should defaults be set for \pkg{ggplot2} \emph{geoms}?
Defaults to TRUE. To restore ggplot's defaults, or the previously set geom Defaults to TRUE. To restore ggplot's defaults, or the previously set geom
defaults, see \code{\link[=theme_xaringan_restore_defaults]{theme_xaringan_restore_defaults()}}.} defaults, see \code{\link[=theme_xaringan_restore_defaults]{theme_xaringan_restore_defaults()}}.}


\item{accent_color}{Color for titles and accents, inherits from \item{accent_color}{Color for titles and accents, inherits from
\code{header_color} or \code{text_color}. Used for the \code{title} base setting in \code{header_color} or \code{text_color}. Used for the \code{title} base setting in
\code{\link[ggplot2:theme]{ggplot2::theme()}}, and additionally for setting the \code{color} or \code{fill} of \code{\link[ggplot2:theme]{ggplot2::theme()}}, and additionally for setting the \code{color} or \code{fill} of
\link{ggplot2} geom defaults.}
\pkg{ggplot2} geom defaults.}


\item{accent_secondary_color}{Color for secondary accents, inherits from \item{accent_secondary_color}{Color for secondary accents, inherits from
\code{text_bold_color} or \code{accent_color}. Used only when setting \link{ggplot2} geom
\code{text_bold_color} or \code{accent_color}. Used only when setting \pkg{ggplot2} geom
defaults.} defaults.}


\item{text_font}{Font to use for text elements, passed to \item{text_font}{Font to use for text elements, passed to
\description{ \description{
\strong{Lifecycle:} \href{https://www.tidyverse.org/lifecycle/#experimental}{Experimental}. \strong{Lifecycle:} \href{https://www.tidyverse.org/lifecycle/#experimental}{Experimental}.


Provides a base plot theme for \link{ggplot2} to match the \link{xaringan} slide theme
Provides a base plot theme for \pkg{ggplot2} to match the \pkg{xaringan} slide theme
created by \link{xaringanthemer}. The theme is designed to create a general plot created by \link{xaringanthemer}. The theme is designed to create a general plot
style from two colors, a \code{background_color} and a \code{text_color} (or foreground style from two colors, a \code{background_color} and a \code{text_color} (or foreground
color). Also accepts an \code{accent_color} and an \code{accent_secondary_color} that are color). Also accepts an \code{accent_color} and an \code{accent_secondary_color} that are

+ 5
- 5
man/theme_xaringan_inverse.Rd Wyświetl plik

\item{accent_color}{Color for titles and accents, inherits from \item{accent_color}{Color for titles and accents, inherits from
\code{header_color} or \code{text_color}. Used for the \code{title} base setting in \code{header_color} or \code{text_color}. Used for the \code{title} base setting in
\code{\link[ggplot2:theme]{ggplot2::theme()}}, and additionally for setting the \code{color} or \code{fill} of \code{\link[ggplot2:theme]{ggplot2::theme()}}, and additionally for setting the \code{color} or \code{fill} of
\link{ggplot2} geom defaults.}
\pkg{ggplot2} geom defaults.}
\item{accent_secondary_color}{Color for secondary accents, inherits from \item{accent_secondary_color}{Color for secondary accents, inherits from
\code{text_bold_color} or \code{accent_color}. Used only when setting \link{ggplot2} geom
\code{text_bold_color} or \code{accent_color}. Used only when setting \pkg{ggplot2} geom
defaults.} defaults.}
\item{set_ggplot_defaults}{Should defaults be set for \link{ggplot2} \emph{geoms}?
\item{set_ggplot_defaults}{Should defaults be set for \pkg{ggplot2} \emph{geoms}?
Defaults to TRUE. To restore ggplot's defaults, or the previously set geom Defaults to TRUE. To restore ggplot's defaults, or the previously set geom
defaults, see \code{\link[=theme_xaringan_restore_defaults]{theme_xaringan_restore_defaults()}}.} defaults, see \code{\link[=theme_xaringan_restore_defaults]{theme_xaringan_restore_defaults()}}.}
\item{text_font}{Font to use for text elements, passed to \item{text_font}{Font to use for text elements, passed to
\description{ \description{
\strong{Lifecycle:} \href{https://www.tidyverse.org/lifecycle/#experimental}{Experimental}. \strong{Lifecycle:} \href{https://www.tidyverse.org/lifecycle/#experimental}{Experimental}.


A \link{ggplot2} xaringanthemer plot theme to seamlessly match the "inverse"
\link{xaringan} slide colors and styles as styled by \link{xaringanthemer}.
A \pkg{ggplot2} xaringanthemer plot theme to seamlessly match the "inverse"
\pkg{xaringan} slide colors and styles as styled by \link{xaringanthemer}.
} }
\examples{ \examples{
if (requireNamespace("ggplot2", quietly = TRUE)) { if (requireNamespace("ggplot2", quietly = TRUE)) {

+ 10
- 5
man/theme_xaringan_set_defaults.Rd Wyświetl plik

% Please edit documentation in R/ggplot2.R % Please edit documentation in R/ggplot2.R
\name{theme_xaringan_set_defaults} \name{theme_xaringan_set_defaults}
\alias{theme_xaringan_set_defaults} \alias{theme_xaringan_set_defaults}
\alias{xaringan_theme_restore_defaults}
\alias{theme_xaringan_restore_defaults}
\title{Set and Restore ggplot2 geom Defaults} \title{Set and Restore ggplot2 geom Defaults}
\usage{ \usage{
theme_xaringan_set_defaults(text_color = NULL, background_color = NULL, theme_xaringan_set_defaults(text_color = NULL, background_color = NULL,
accent_color = text_color, accent_secondary_color = accent_color, accent_color = text_color, accent_secondary_color = accent_color,
text_family = NULL)
text_font = NULL)


xaringan_theme_restore_defaults()
theme_xaringan_restore_defaults()
} }
\arguments{ \arguments{
\item{text_color}{Color for text and foreground, inherits from \code{text_color}} \item{text_color}{Color for text and foreground, inherits from \code{text_color}}


\item{accent_secondary_color}{Color for secondary accents, inherits from \item{accent_secondary_color}{Color for secondary accents, inherits from
\code{text_bold_color}} \code{text_bold_color}}

\item{text_font}{Font to use for text elements, passed to
\code{\link[sysfonts:font_add_google]{sysfonts::font_add_google()}}, if available and \code{text_font_use_google} is
\code{TRUE}. Inherits from \code{text_font_family}.}
} }
\value{ \value{
Invisibly returns a list of the current ggplot2 geom defaults Invisibly returns a list of the current ggplot2 geom defaults
\description{ \description{
\strong{Lifecycle:} \href{https://www.tidyverse.org/lifecycle/#experimental}{Experimental}. \strong{Lifecycle:} \href{https://www.tidyverse.org/lifecycle/#experimental}{Experimental}.


Set \link{ggplot2} \emph{geom} defaults to match \code{\link[=theme_xaringan]{theme_xaringan()}} with
Set \pkg{ggplot2} \emph{geom} defaults to match \code{\link[=theme_xaringan]{theme_xaringan()}} with
\code{theme_xaringan_set_defaults()} and restore the standard or previously-set \code{theme_xaringan_set_defaults()} and restore the standard or previously-set
defaults with \code{theme_xaringan_restore_defaults()}. By default, defaults with \code{theme_xaringan_restore_defaults()}. By default,
\code{theme_xaringan_set_defaults()} is run with \code{\link[=theme_xaringan]{theme_xaringan()}} or \code{theme_xaringan_set_defaults()} is run with \code{\link[=theme_xaringan]{theme_xaringan()}} or
} }
\section{Functions}{ \section{Functions}{
\itemize{ \itemize{
\item \code{xaringan_theme_restore_defaults}: Restore previous or standard \link{ggplot2} \emph{geom} defaults.
\item \code{theme_xaringan_restore_defaults}: Restore previous or standard
\pkg{ggplot2} \emph{geom} defaults.
}} }}


\seealso{ \seealso{

Ładowanie…
Anuluj
Zapisz