😎 Give your xaringan slides some style
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

116 lines
4.0KB

  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. )
  21. }
  22. \arguments{
  23. \item{text_color}{Color for text and foreground}
  24. \item{background_color}{Color for background}
  25. \item{...}{Ignored}
  26. \item{set_ggplot_defaults}{Should defaults be set for \pkg{ggplot2} \emph{geoms}?
  27. Defaults to TRUE. To restore ggplot's defaults, or the previously set geom
  28. defaults, see \code{\link[=theme_xaringan_restore_defaults]{theme_xaringan_restore_defaults()}}.}
  29. \item{accent_color}{Color for titles and accents, inherits from
  30. \code{header_color} or \code{text_color}. Used for the \code{title} base setting in
  31. \code{\link[ggplot2:theme]{ggplot2::theme()}}, and additionally for setting the \code{color} or \code{fill} of
  32. \pkg{ggplot2} geom defaults.}
  33. \item{accent_secondary_color}{Color for secondary accents, inherits from
  34. \code{text_bold_color} or \code{accent_color}. Used only when setting \pkg{ggplot2} geom
  35. defaults.}
  36. \item{text_font}{Font to use for text elements, passed to
  37. \code{\link[sysfonts:font_add_google]{sysfonts::font_add_google()}}, if available and \code{text_font_use_google} is
  38. \code{TRUE}. Inherits from \code{text_font_family}.}
  39. \item{text_font_use_google}{Is \code{text_font} available on \href{https://fonts.google.com}{Google Fonts}?}
  40. \item{text_font_size}{Base text font size, inherits from \code{text_font_size}, or
  41. defaults to 11.}
  42. \item{title_font}{Font to use for title elements, passed to
  43. \code{\link[sysfonts:font_add_google]{sysfonts::font_add_google()}}, if available and \code{title_font_use_google} is
  44. \code{TRUE}. Inherits from \code{title_font_family}.}
  45. \item{title_font_use_google}{Is \code{title_font} available on \href{https://fonts.google.com}{Google Fonts}?}
  46. \item{title_font_size}{Base text font size, inherits from \code{title_font_size},
  47. or defaults to 14.}
  48. }
  49. \value{
  50. A ggplot2 theme
  51. }
  52. \description{
  53. \strong{Lifecycle:} \href{https://www.tidyverse.org/lifecycle/#experimental}{Experimental}.
  54. Provides a base plot theme for \pkg{ggplot2} to match the \pkg{xaringan} slide theme
  55. created by \link{xaringanthemer}. The theme is designed to create a general plot
  56. style from two colors, a \code{background_color} and a \code{text_color} (or foreground
  57. color). Also accepts an \code{accent_color} and an \code{accent_secondary_color} that are
  58. \link{xaringanthemer} is not required for the base theme. Use
  59. \code{\link[=theme_xaringan]{theme_xaringan()}} or \code{\link[=theme_xaringan_inverse]{theme_xaringan_inverse()}} in xaringan slides styled by
  60. xaringanthemer for a plot theme that matches the slide style.
  61. }
  62. \examples{
  63. has_ggplot2 <- requireNamespace("ggplot2", quietly = TRUE)
  64. if (interactive() && has_ggplot2) {
  65. library(ggplot2)
  66. ggplot(iris) +
  67. aes(Petal.Length, Petal.Width) +
  68. geom_point() +
  69. theme_xaringan_base(
  70. text_color = "#e1e5f2",
  71. background_color = "#021c25",
  72. accent_color = "#1f7a8c",
  73. set_ggplot_defaults = TRUE
  74. ) +
  75. labs(
  76. title = "Basic Iris Plot",
  77. subtitle = "+ theme_xaringan_base()",
  78. caption = "{xaringanthemer}"
  79. )
  80. ggplot(iris) +
  81. aes(Petal.Length, Petal.Width) +
  82. geom_point() +
  83. theme_xaringan_base(
  84. text_color = "#021c25",
  85. background_color = "#e1e5f2",
  86. accent_color = "#1f7a8c",
  87. set_ggplot_defaults = TRUE
  88. ) +
  89. labs(
  90. title = "Basic Iris Plot",
  91. subtitle = "+ theme_xaringan_base()",
  92. caption = "{xaringanthemer}"
  93. )
  94. }
  95. }
  96. \seealso{
  97. Other xaringanthemer ggplot2 themes:
  98. \code{\link{theme_xaringan_inverse}()},
  99. \code{\link{theme_xaringan_set_defaults}()},
  100. \code{\link{theme_xaringan}()}
  101. }
  102. \concept{xaringanthemer ggplot2 themes}