😎 Give your xaringan slides some style
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

136 satır
4.7KB

  1. % Generated by roxygen2: do not edit by hand
  2. % Please edit documentation in R/ggplot2.R
  3. \name{theme_xaringan_base}
  4. \alias{theme_xaringan_base}
  5. \title{The ggplot2 xaringanthemer base plot theme}
  6. \usage{
  7. theme_xaringan_base(
  8. text_color,
  9. background_color,
  10. ...,
  11. set_ggplot_defaults = TRUE,
  12. accent_color = NULL,
  13. accent_secondary_color = NULL,
  14. text_font = NULL,
  15. text_font_use_google = NULL,
  16. text_font_size = NULL,
  17. title_font = NULL,
  18. title_font_use_google = NULL,
  19. title_font_size = NULL,
  20. use_showtext = TRUE
  21. )
  22. }
  23. \arguments{
  24. \item{text_color}{Color for text and foreground}
  25. \item{background_color}{Color for background}
  26. \item{...}{Ignored}
  27. \item{set_ggplot_defaults}{Should defaults be set for \pkg{ggplot2} \emph{geoms}?
  28. Defaults to TRUE. To restore ggplot's defaults, or the previously set geom
  29. defaults, see \code{\link[=theme_xaringan_restore_defaults]{theme_xaringan_restore_defaults()}}.}
  30. \item{accent_color}{Color for titles and accents, inherits from
  31. \code{header_color} or \code{text_color}. Used for the \code{title} base setting in
  32. \code{\link[ggplot2:theme]{ggplot2::theme()}}, and additionally for setting the \code{color} or \code{fill} of
  33. \pkg{ggplot2} geom defaults.}
  34. \item{accent_secondary_color}{Color for secondary accents, inherits from
  35. \code{text_bold_color} or \code{accent_color}. Used only when setting \pkg{ggplot2} geom
  36. defaults.}
  37. \item{text_font}{Font to use for text elements, passed to
  38. \code{\link[sysfonts:font_add_google]{sysfonts::font_add_google()}}, if available and \code{text_font_use_google} is
  39. \code{TRUE}. Inherits from \code{text_font_family}. If manually specified, can be a
  40. \code{\link[=google_font]{google_font()}}.}
  41. \item{text_font_use_google}{Is \code{text_font} available on \href{https://fonts.google.com}{Google Fonts}?}
  42. \item{text_font_size}{Base text font size, inherits from \code{text_font_size}, or
  43. defaults to 11.}
  44. \item{title_font}{Font to use for title elements, passed to
  45. \code{\link[sysfonts:font_add_google]{sysfonts::font_add_google()}}, if available and \code{title_font_use_google} is
  46. \code{TRUE}. Inherits from \code{title_font_family}. If manually specified, can be a
  47. \code{\link[=google_font]{google_font()}}.}
  48. \item{title_font_use_google}{Is \code{title_font} available on \href{https://fonts.google.com}{Google Fonts}?}
  49. \item{title_font_size}{Base text font size, inherits from \code{title_font_size},
  50. or defaults to 14.}
  51. \item{use_showtext}{If \code{TRUE} (default) the \pkg{showtext} package will be
  52. used to register Google fonts. Set to \code{FALSE} to disable this feature
  53. entirely, which may result in errors during plotting if the fonts used are
  54. not available locally.}
  55. }
  56. \value{
  57. A ggplot2 theme
  58. }
  59. \description{
  60. \strong{Lifecycle:} \href{https://www.tidyverse.org/lifecycle/#maturing}{Maturing}
  61. Provides a base plot theme for \pkg{ggplot2} to match the \pkg{xaringan}
  62. slide theme created by \link{xaringanthemer}. The theme is designed to create a
  63. general plot style from two colors, a \code{background_color} and a \code{text_color}
  64. (or foreground color). Also accepts an \code{accent_color} and an
  65. \code{accent_secondary_color} that are \link{xaringanthemer} is not required for the
  66. base theme. Use \code{\link[=theme_xaringan]{theme_xaringan()}} or \code{\link[=theme_xaringan_inverse]{theme_xaringan_inverse()}} in xaringan
  67. slides styled by xaringanthemer for a plot theme that matches the slide
  68. style. See \code{vignette("ggplot2-themes")} for more information and examples.
  69. }
  70. \examples{
  71. # Requires ggplot2
  72. has_ggplot2 <- requireNamespace("ggplot2", quietly = TRUE)
  73. if (has_ggplot2) {
  74. library(ggplot2)
  75. plot1 <- ggplot(iris) +
  76. aes(Petal.Length, Petal.Width) +
  77. geom_point() +
  78. theme_xaringan_base(
  79. text_color = "#602f6b", # imperial
  80. background_color = "#f8f8f8", # light gray
  81. accent_color = "#317873", # myrtle green
  82. title_font = "sans",
  83. text_font = "serif",
  84. set_ggplot_defaults = TRUE
  85. ) +
  86. labs(
  87. title = "Basic Iris Plot",
  88. subtitle = "+ theme_xaringan_base()",
  89. caption = "xaringanthemer"
  90. )
  91. print(plot1)
  92. plot2 <- ggplot(iris) +
  93. aes(Sepal.Width) +
  94. geom_histogram(binwidth = 0.1) +
  95. theme_xaringan_base(
  96. text_color = "#a8a9c8", # light purple
  97. background_color = "#303163", # deep slate purple
  98. accent_color = "#ffff99", # canary yellow
  99. title_font = "sans",
  100. text_font = "serif",
  101. set_ggplot_defaults = TRUE
  102. ) +
  103. labs(
  104. title = "Basic Iris Plot",
  105. subtitle = "+ theme_xaringan_base()",
  106. caption = "xaringanthemer"
  107. )
  108. print(plot2)
  109. }
  110. }
  111. \seealso{
  112. Other xaringanthemer ggplot2 themes:
  113. \code{\link{theme_xaringan_inverse}()},
  114. \code{\link{theme_xaringan_set_defaults}()},
  115. \code{\link{theme_xaringan}()}
  116. }
  117. \concept{xaringanthemer ggplot2 themes}