R/ggplot2_themes.R

Defines functions md_theme_classic md_theme_minimal md_theme_dark md_theme_light md_theme_linedraw md_theme_bw md_theme_grey md_theme_gray

Documented in md_theme_bw md_theme_classic md_theme_dark md_theme_gray md_theme_grey md_theme_light md_theme_linedraw md_theme_minimal

#' ggplot2 Markdown Themes
#'
#' `{ggplot2}` themes supporting markdown syntax
#'
#' @param ... Arguments passed on to the corresponding theme in package `{ggplot2}`
#'
#' @return An object of class `theme` that can be added to any `ggplot`
#'
#' @seealso [as_md_theme()]
#'
#' @examples
#' library(ggplot2)
#' data(mtcars)
#'
#' p <- ggplot(mtcars, aes(hp, mpg)) +
#'   geom_point() +
#'   labs(
#'     title = "A **bold** title",
#'     subtitle = "An *italics* subtitle",
#'     caption = "A <span style = 'color:blue'>blue</span> caption"
#'   )
#'
#' # With a 'usual' theme the text is not rendered
#' p
#'
#' # By adding an 'md' theme the text is rendered properly
#' p + md_theme_gray()
#'
#' @rdname ggplot2_themes
#' @export
md_theme_gray <- function(...) {
  as_md_theme(ggplot2::theme_gray(...))
}

#' @rdname ggplot2_themes
#' @export
md_theme_grey <- function(...) {
  as_md_theme(ggplot2::theme_grey(...))
}

#' @rdname ggplot2_themes
#' @export
md_theme_bw <- function(...) {
  as_md_theme(ggplot2::theme_bw(...))
}

#' @rdname ggplot2_themes
#' @export
md_theme_linedraw <- function(...) {
  as_md_theme(ggplot2::theme_linedraw(...))
}

#' @rdname ggplot2_themes
#' @export
md_theme_light <- function(...) {
  as_md_theme(ggplot2::theme_light(...))
}

#' @rdname ggplot2_themes
#' @export
md_theme_dark <- function(...) {
  as_md_theme(ggplot2::theme_dark(...))
}

#' @rdname ggplot2_themes
#' @export
md_theme_minimal <- function(...) {
  as_md_theme(ggplot2::theme_minimal(...))
}

#' @rdname ggplot2_themes
#' @export
md_theme_classic <- function(...) {
  as_md_theme(ggplot2::theme_classic(...))
}

Try the mdthemes package in your browser

Any scripts or data that you put into this service are public.

mdthemes documentation built on July 1, 2020, 9:08 p.m.