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

156 lines
4.6KB

  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{Themed 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. na.value = "grey50"
  43. )
  44. scale_xaringan_fill_continuous(
  45. ...,
  46. color = NULL,
  47. begin = 0,
  48. end = 1,
  49. inverse = FALSE
  50. )
  51. scale_xaringan_color_continuous(
  52. ...,
  53. color = NULL,
  54. begin = 0,
  55. end = 1,
  56. inverse = FALSE
  57. )
  58. scale_xaringan_colour_continuous(
  59. ...,
  60. color = NULL,
  61. begin = 0,
  62. end = 1,
  63. inverse = FALSE
  64. )
  65. }
  66. \arguments{
  67. \item{aes_type}{The type of aesthetic to which the scale is being applied.
  68. One of "color", "colour", or "fill".}
  69. \item{...}{Arguments passed on to either the \pkg{colorspace} scale
  70. functions — one of \code{\link[colorspace:scale_colour_discrete_sequential]{colorspace::scale_color_discrete_sequential()}},
  71. \code{\link[colorspace:scale_colour_continuous_sequential]{colorspace::scale_color_continuous_sequential()}},
  72. \code{\link[colorspace:scale_colour_discrete_sequential]{colorspace::scale_fill_discrete_sequential()}}, or
  73. \code{\link[colorspace:scale_colour_continuous_sequential]{colorspace::scale_fill_continuous_sequential()}} — or to
  74. \link[ggplot2:continuous_scale]{ggplot2::continuous_scale} or \link[ggplot2:discrete_scale]{ggplot2::discrete_scale}.}
  75. \item{color}{A color value, in hex, to override the default color. Otherwise,
  76. the primary color of the resulting scale is chosen from the xaringanthemer
  77. slide styles.}
  78. \item{direction}{Direction of the discrete scale. Use values less than 0 to
  79. reverse the direction, e.g. \code{direction = -1}.}
  80. \item{inverse}{If \code{color} is not supplied and \code{inverse = TRUE}, a primary
  81. color is chosen to work well with the inverse slide styles, namely the
  82. value of \code{inverse_header_color}}
  83. \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.}
  84. \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.}
  85. \item{na.value}{Color to be used for missing data points.}
  86. }
  87. \description{
  88. \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#maturing}{\figure{lifecycle-maturing.svg}{options: alt='[Maturing]'}}}{\strong{[Maturing]}}
  89. Color and fill single-color scales for discrete and continuous values,
  90. created using the primary accent color of the xaringanthemer styles. See
  91. \code{vignette("ggplot2-themes")} for more information and examples of
  92. \pkg{xaringanthemer}'s \pkg{ggplot2}-related functions.
  93. }
  94. \examples{
  95. # Requires ggplot2
  96. has_ggplot2 <- requireNamespace("ggplot2", quietly = TRUE)
  97. if (has_ggplot2) {
  98. library(ggplot2)
  99. # Saving the theme to a temp file because this is an example
  100. path_to_css_file <- tempfile(fileext = ".css")
  101. # Create the xaringan theme: dark blue background with teal green accents
  102. style_duo(
  103. primary_color = "#002b36",
  104. secondary_color = "#31b09e",
  105. # Using basic fonts for this example, but the plot theme will
  106. # automatically use your theme font if you use Google fonts
  107. text_font_family = "sans",
  108. header_font_family = "serif",
  109. outfile = path_to_css_file
  110. )
  111. # Here's some very basic example data
  112. ex <- data.frame(
  113. name = c("Couple", "Few", "Lots", "Many"),
  114. n = c(2, 3, 5, 7)
  115. )
  116. # Fill color scales demo
  117. ggplot(ex) +
  118. aes(name, n, fill = n) +
  119. geom_col() +
  120. ggtitle("Matching fill scales") +
  121. # themed to match the slides: dark blue background with teal text
  122. theme_xaringan() +
  123. # Fill color matches teal text
  124. scale_xaringan_fill_continuous()
  125. # Color scales demo
  126. ggplot(ex) +
  127. aes(name, y = 1, color = name) +
  128. geom_point(size = 10) +
  129. ggtitle("Matching color scales") +
  130. # themed to match the slides: dark blue background with teal text
  131. theme_xaringan() +
  132. # Fill color matches teal text
  133. scale_xaringan_color_discrete(direction = -1)
  134. }
  135. }