😎 Give your xaringan slides some style
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

157 lines
4.7KB

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