😎 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.

152 lines
4.3KB

  1. % Generated by roxygen2: do not edit by hand
  2. % Please edit documentation in R/ggplot2.R
  3. \name{scale_xaringan}
  4. \alias{scale_xaringan}
  5. \alias{scale_xaringan_discrete}
  6. \alias{scale_xaringan_fill_discrete}
  7. \alias{scale_xaringan_color_discrete}
  8. \alias{scale_xaringan_colour_discrete}
  9. \alias{scale_xaringan_continuous}
  10. \alias{scale_xaringan_fill_continuous}
  11. \alias{scale_xaringan_color_continuous}
  12. \alias{scale_xaringan_colour_continuous}
  13. \title{Xaringan Themer ggplot2 Scales}
  14. \usage{
  15. scale_xaringan_discrete(
  16. aes_type = c("color", "colour", "fill"),
  17. ...,
  18. color = NULL,
  19. direction = 1,
  20. inverse = FALSE
  21. )
  22. scale_xaringan_fill_discrete(..., color = NULL, direction = 1, inverse = FALSE)
  23. scale_xaringan_color_discrete(
  24. ...,
  25. color = NULL,
  26. direction = 1,
  27. inverse = FALSE
  28. )
  29. scale_xaringan_colour_discrete(
  30. ...,
  31. color = NULL,
  32. direction = 1,
  33. inverse = FALSE
  34. )
  35. scale_xaringan_continuous(
  36. aes_type = c("color", "colour", "fill"),
  37. ...,
  38. color = NULL,
  39. begin = 0,
  40. end = 1,
  41. inverse = FALSE
  42. )
  43. scale_xaringan_fill_continuous(
  44. ...,
  45. color = NULL,
  46. begin = 0,
  47. end = 1,
  48. inverse = FALSE
  49. )
  50. scale_xaringan_color_continuous(
  51. ...,
  52. color = NULL,
  53. begin = 0,
  54. end = 1,
  55. inverse = FALSE
  56. )
  57. scale_xaringan_colour_continuous(
  58. ...,
  59. color = NULL,
  60. begin = 0,
  61. end = 1,
  62. inverse = FALSE
  63. )
  64. }
  65. \arguments{
  66. \item{aes_type}{The type of aesthetic to which the scale is being applied.
  67. One of "color", "colour", or "fill".}
  68. \item{...}{Arguments passed on to either the \pkg{colorspace} scale
  69. functions — one of \link[colorspace:scale_color_discrete_sequential]{colorspace::scale_color_discrete_sequential},
  70. \link[colorspace:scale_color_continuous_sequential]{colorspace::scale_color_continuous_sequential},
  71. \link[colorspace:scale_fill_discrete_sequential]{colorspace::scale_fill_discrete_sequential}, or
  72. \link[colorspace:scale_fill_continuous_sequential]{colorspace::scale_fill_continuous_sequential} — or to
  73. \link[ggplot2:continuous_scale]{ggplot2::continuous_scale} or \link[ggplot2:discrete_scale]{ggplot2::discrete_scale}.}
  74. \item{color}{A color value, in hex, to override the default color. Otherwise,
  75. the primary color of the resulting scale is chosen from the xaringanthemer
  76. slide styles.}
  77. \item{direction}{Direction of the discrete scale. Use values less than 0 to
  78. reverse the direction, e.g. \code{direction = -1}.}
  79. \item{inverse}{If \code{color} is not supplied and \code{inverse = TRUE}, a primary
  80. color is chosen to work well with the inverse slide styles, namely the
  81. value of \code{inverse_header_color}}
  82. \item{begin}{Number in the range of \code{[0, 1]} indicating to which point in the color scale the smallest data value should be mapped.}
  83. \item{end}{Number in the range of \code{[0, 1]} indicating to which point in the color scale the largest data value should be mapped.}
  84. }
  85. \description{
  86. \strong{Lifecycle:} \href{https://www.tidyverse.org/lifecycle/#maturing}{Maturing}
  87. Color and fill single-color scales for discrete and continuous values,
  88. created using the primary accent color of the xaringanthemer styles.
  89. }
  90. \examples{
  91. # Requires ggplot2
  92. has_ggplot2 <- requireNamespace("ggplot2", quietly = TRUE)
  93. if (has_ggplot2) {
  94. library(ggplot2)
  95. # Saving the theme to a temp file because this is an example
  96. path_to_css_file <- tempfile(fileext = ".css")
  97. # Create the xaringan theme: dark blue background with teal green accents
  98. style_duo(
  99. primary_color = "#002b36",
  100. secondary_color = "#31b09e",
  101. # Using basic fonts for this example, but the plot theme will
  102. # automatically use your theme font if you use Google fonts
  103. text_font_family = "sans",
  104. header_font_family = "serif",
  105. outfile = path_to_css_file
  106. )
  107. # Here's some very basic example data
  108. ex <- data.frame(
  109. name = c("Couple", "Few", "Lots", "Many"),
  110. n = c(2, 3, 5, 7)
  111. )
  112. # Fill color scales demo
  113. ggplot(ex) +
  114. aes(name, n, fill = n) +
  115. geom_col() +
  116. ggtitle("Matching fill scales") +
  117. # themed to match the slides: dark blue background with teal text
  118. theme_xaringan() +
  119. # Fill color matches teal text
  120. scale_xaringan_fill_continuous()
  121. # Color scales demo
  122. ggplot(ex) +
  123. aes(name, y = 1, color = name) +
  124. geom_point(size = 10) +
  125. ggtitle("Matching color scales") +
  126. # themed to match the slides: dark blue background with teal text
  127. theme_xaringan() +
  128. # Fill color matches teal text
  129. scale_xaringan_color_discrete(direction = -1)
  130. }
  131. }