😎 Give your xaringan slides some style
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

127 lines
4.2KB

  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. # Requires ggplot2
  64. has_ggplot2 <- requireNamespace("ggplot2", quietly = TRUE)
  65. if (has_ggplot2) {
  66. library(ggplot2)
  67. plot1 <- ggplot(iris) +
  68. aes(Petal.Length, Petal.Width) +
  69. geom_point() +
  70. theme_xaringan_base(
  71. text_color = "#602f6b", # imperial
  72. background_color = "#f8f8f8", # light gray
  73. accent_color = "#317873", # myrtle green
  74. title_font = "sans",
  75. text_font = "serif",
  76. set_ggplot_defaults = TRUE
  77. ) +
  78. labs(
  79. title = "Basic Iris Plot",
  80. subtitle = "+ theme_xaringan_base()",
  81. caption = "xaringanthemer"
  82. )
  83. print(plot1)
  84. plot2 <- ggplot(iris) +
  85. aes(Sepal.Width) +
  86. geom_histogram(binwidth = 0.1) +
  87. theme_xaringan_base(
  88. text_color = "#a8a9c8", # light purple
  89. background_color = "#303163", # deep slate purple
  90. accent_color = "#ffff99", # canary yellow
  91. title_font = "sans",
  92. text_font = "serif",
  93. set_ggplot_defaults = TRUE
  94. ) +
  95. labs(
  96. title = "Basic Iris Plot",
  97. subtitle = "+ theme_xaringan_base()",
  98. caption = "xaringanthemer"
  99. )
  100. print(plot2)
  101. }
  102. }
  103. \seealso{
  104. Other xaringanthemer ggplot2 themes:
  105. \code{\link{theme_xaringan_inverse}()},
  106. \code{\link{theme_xaringan_set_defaults}()},
  107. \code{\link{theme_xaringan}()}
  108. }
  109. \concept{xaringanthemer ggplot2 themes}