😎 Give your xaringan slides some style
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

116 lines
4.3KB

  1. % Generated by roxygen2: do not edit by hand
  2. % Please edit documentation in R/ggplot2.R
  3. \name{theme_xaringan}
  4. \alias{theme_xaringan}
  5. \title{A Plot Theme for ggplot2 by xaringanthemer}
  6. \usage{
  7. theme_xaringan(
  8. text_color = NULL,
  9. background_color = NULL,
  10. accent_color = NULL,
  11. accent_secondary_color = NULL,
  12. css_file = NULL,
  13. set_ggplot_defaults = TRUE,
  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 = NULL
  21. )
  22. }
  23. \arguments{
  24. \item{text_color}{Color for text and foreground, inherits from \code{text_color}}
  25. \item{background_color}{Color for background, inherits from
  26. \code{background_color}}
  27. \item{accent_color}{Color for titles and accents, inherits from
  28. \code{header_color}}
  29. \item{accent_secondary_color}{Color for secondary accents, inherits from
  30. \code{text_bold_color}}
  31. \item{css_file}{Path to a \pkg{xaringanthemer} CSS file, from which the
  32. theme variables and values will be inferred. In general, if you use the
  33. \pkg{xaringathemer} defaults, you will not need to set this. This feature
  34. lets you create a \pkg{ggplot2} theme for your \pkg{xaringan} slides, even
  35. if you have only saved your theme CSS file and you aren't creating your
  36. CSS theme with \pkg{xaringanthemer} in your slides' source file.}
  37. \item{set_ggplot_defaults}{Should defaults be set for \pkg{ggplot2} \emph{geoms}?
  38. Defaults to TRUE. To restore ggplot's defaults, or the previously set geom
  39. defaults, see \code{\link[=theme_xaringan_restore_defaults]{theme_xaringan_restore_defaults()}}.}
  40. \item{text_font}{Font to use for text elements, passed to
  41. \code{\link[sysfonts:font_add_google]{sysfonts::font_add_google()}}, if available and \code{text_font_use_google} is
  42. \code{TRUE}. Inherits from \code{text_font_family}. If manually specified, can be a
  43. \code{\link[=google_font]{google_font()}}.}
  44. \item{text_font_use_google}{Is \code{text_font} available on \href{https://fonts.google.com}{Google Fonts}?}
  45. \item{text_font_size}{Base text font size, inherits from \code{text_font_size}, or
  46. defaults to 11.}
  47. \item{title_font}{Font to use for title elements, passed to
  48. \code{\link[sysfonts:font_add_google]{sysfonts::font_add_google()}}, if available and \code{title_font_use_google} is
  49. \code{TRUE}. Inherits from \code{title_font_family}. If manually specified, can be a
  50. \code{\link[=google_font]{google_font()}}.}
  51. \item{title_font_use_google}{Is \code{title_font} available on \href{https://fonts.google.com}{Google Fonts}?}
  52. \item{title_font_size}{Base text font size, inherits from \code{title_font_size},
  53. or defaults to 14.}
  54. \item{use_showtext}{If \code{TRUE} the \pkg{showtext} package will be
  55. used to register Google fonts. Set to \code{FALSE} to disable this feature
  56. entirely, which may result in errors during plotting if the fonts used are
  57. not available locally. The default is \code{TRUE} when the \pkg{showtext}
  58. package is installed.}
  59. }
  60. \value{
  61. A ggplot2 theme
  62. }
  63. \description{
  64. \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#maturing}{\figure{lifecycle-maturing.svg}{options: alt='[Maturing]'}}}{\strong{[Maturing]}}
  65. Creates \pkg{ggplot2} themes to match the xaringanthemer theme used in the
  66. \pkg{xaringan} slides that seamlessly matches the "normal" slide colors and
  67. styles. See \code{vignette("ggplot2-themes")} for more information and examples.
  68. }
  69. \examples{
  70. # Requires ggplot2
  71. has_ggplot2 <- requireNamespace("ggplot2", quietly = TRUE)
  72. if (has_ggplot2) {
  73. # Because this is an example, we'll save the CSS to a temp file
  74. path_to_css_file <- tempfile(fileext = ".css")
  75. # Create the xaringan theme: dark blue background with teal green accents
  76. style_duo(
  77. primary_color = "#002b36",
  78. secondary_color = "#31b09e",
  79. # Using basic fonts for this example, but the plot theme will
  80. # automatically use your theme font if you use Google fonts
  81. text_font_family = "sans",
  82. header_font_family = "serif",
  83. outfile = path_to_css_file
  84. )
  85. library(ggplot2)
  86. ggplot(mpg) +
  87. aes(cty, hwy) +
  88. geom_point() +
  89. ggtitle("Fuel Efficiency of Various Cars") +
  90. theme_xaringan()
  91. }
  92. }
  93. \seealso{
  94. Other xaringanthemer ggplot2 themes:
  95. \code{\link{theme_xaringan_base}()},
  96. \code{\link{theme_xaringan_inverse}()},
  97. \code{\link{theme_xaringan_set_defaults}()}
  98. }
  99. \concept{xaringanthemer ggplot2 themes}