😎 Give your xaringan slides some style
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

154 行
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. )
  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 \code{\link[colorspace:scale_colour_discrete_sequential]{colorspace::scale_color_discrete_sequential()}},
  70. \code{\link[colorspace:scale_colour_continuous_sequential]{colorspace::scale_color_continuous_sequential()}},
  71. \code{\link[colorspace:scale_colour_discrete_sequential]{colorspace::scale_fill_discrete_sequential()}}, or
  72. \code{\link[colorspace:scale_colour_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. \ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#maturing}{\figure{lifecycle-maturing.svg}{options: alt='[Maturing]'}}}{\strong{[Maturing]}}
  87. Color and fill single-color scales for discrete and continuous values,
  88. created using the primary accent color of the xaringanthemer styles. See
  89. \code{vignette("ggplot2-themes")} for more information and examples of
  90. \pkg{xaringanthemer}'s \pkg{ggplot2}-related functions.
  91. }
  92. \examples{
  93. # Requires ggplot2
  94. has_ggplot2 <- requireNamespace("ggplot2", quietly = TRUE)
  95. if (has_ggplot2) {
  96. library(ggplot2)
  97. # Saving the theme to a temp file because this is an example
  98. path_to_css_file <- tempfile(fileext = ".css")
  99. # Create the xaringan theme: dark blue background with teal green accents
  100. style_duo(
  101. primary_color = "#002b36",
  102. secondary_color = "#31b09e",
  103. # Using basic fonts for this example, but the plot theme will
  104. # automatically use your theme font if you use Google fonts
  105. text_font_family = "sans",
  106. header_font_family = "serif",
  107. outfile = path_to_css_file
  108. )
  109. # Here's some very basic example data
  110. ex <- data.frame(
  111. name = c("Couple", "Few", "Lots", "Many"),
  112. n = c(2, 3, 5, 7)
  113. )
  114. # Fill color scales demo
  115. ggplot(ex) +
  116. aes(name, n, fill = n) +
  117. geom_col() +
  118. ggtitle("Matching fill scales") +
  119. # themed to match the slides: dark blue background with teal text
  120. theme_xaringan() +
  121. # Fill color matches teal text
  122. scale_xaringan_fill_continuous()
  123. # Color scales demo
  124. ggplot(ex) +
  125. aes(name, y = 1, color = name) +
  126. geom_point(size = 10) +
  127. ggtitle("Matching color scales") +
  128. # themed to match the slides: dark blue background with teal text
  129. theme_xaringan() +
  130. # Fill color matches teal text
  131. scale_xaringan_color_discrete(direction = -1)
  132. }
  133. }