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

333 lines
16KB

  1. <!-- Generated by pkgdown: do not edit by hand -->
  2. <!DOCTYPE html>
  3. <html lang="en">
  4. <head>
  5. <meta charset="utf-8">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  8. <title>The ggplot2 xaringanthemer base plot theme — theme_xaringan_base • xaringanthemer</title>
  9. <!-- jquery -->
  10. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
  11. <!-- Bootstrap -->
  12. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha256-bZLfwXAP04zRMK2BjiO8iu9pf4FbLqX6zitd+tIvLhE=" crossorigin="anonymous" />
  13. <script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha256-nuL8/2cJ5NDSSwnKD8VqreErSWHtnEP9E7AySL+1ev4=" crossorigin="anonymous"></script>
  14. <!-- bootstrap-toc -->
  15. <link rel="stylesheet" href="../bootstrap-toc.css">
  16. <script src="../bootstrap-toc.js"></script>
  17. <!-- Font Awesome icons -->
  18. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/all.min.css" integrity="sha256-mmgLkCYLUQbXn0B1SRqzHar6dCnv9oZFPEC1g1cwlkk=" crossorigin="anonymous" />
  19. <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.12.1/css/v4-shims.min.css" integrity="sha256-wZjR52fzng1pJHwx4aV2AO3yyTOXrcDW7jBpJtTwVxw=" crossorigin="anonymous" />
  20. <!-- clipboard.js -->
  21. <script src="https://cdnjs.cloudflare.com/ajax/libs/clipboard.js/2.0.6/clipboard.min.js" integrity="sha256-inc5kl9MA1hkeYUt+EC3BhlIgyp/2jDIyBLS6k3UxPI=" crossorigin="anonymous"></script>
  22. <!-- headroom.js -->
  23. <script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/headroom.min.js" integrity="sha256-AsUX4SJE1+yuDu5+mAVzJbuYNPHj/WroHuZ8Ir/CkE0=" crossorigin="anonymous"></script>
  24. <script src="https://cdnjs.cloudflare.com/ajax/libs/headroom/0.11.0/jQuery.headroom.min.js" integrity="sha256-ZX/yNShbjqsohH1k95liqY9Gd8uOiE1S4vZc+9KQ1K4=" crossorigin="anonymous"></script>
  25. <!-- pkgdown -->
  26. <link href="../pkgdown.css" rel="stylesheet">
  27. <script src="../pkgdown.js"></script>
  28. <link href="../extra.css" rel="stylesheet">
  29. <meta property="og:title" content="The ggplot2 xaringanthemer base plot theme — theme_xaringan_base" />
  30. <meta property="og:description" content="Lifecycle: Maturing
  31. Provides a base plot theme for ggplot2 to match the xaringan slide theme
  32. created by xaringanthemer. The theme is designed to create a general plot
  33. style from two colors, a background_color and a text_color (or foreground
  34. color). Also accepts an accent_color and an accent_secondary_color that are
  35. xaringanthemer is not required for the base theme. Use
  36. theme_xaringan() or theme_xaringan_inverse() in xaringan slides styled by
  37. xaringanthemer for a plot theme that matches the slide style." />
  38. <meta name="robots" content="noindex">
  39. <!-- mathjax -->
  40. <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js" integrity="sha256-nvJJv9wWKEm88qvoQl9ekL2J+k/RWIsaSScxxlsrv8k=" crossorigin="anonymous"></script>
  41. <script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/config/TeX-AMS-MML_HTMLorMML.js" integrity="sha256-84DKXVJXs0/F8OTMzX4UR909+jtl4G7SPypPavF+GfA=" crossorigin="anonymous"></script>
  42. <!--[if lt IE 9]>
  43. <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
  44. <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
  45. <![endif]-->
  46. </head>
  47. <body data-spy="scroll" data-target="#toc">
  48. <div class="container template-reference-topic">
  49. <header>
  50. <div class="navbar navbar-default navbar-fixed-top" role="navigation">
  51. <div class="container">
  52. <div class="navbar-header">
  53. <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false">
  54. <span class="sr-only">Toggle navigation</span>
  55. <span class="icon-bar"></span>
  56. <span class="icon-bar"></span>
  57. <span class="icon-bar"></span>
  58. </button>
  59. <span class="navbar-brand">
  60. <a class="navbar-link" href="../index.html">xaringanthemer</a>
  61. <span class="version label label-danger" data-toggle="tooltip" data-placement="bottom" title="In-development version">0.2.0.9100</span>
  62. </span>
  63. </div>
  64. <div id="navbar" class="navbar-collapse collapse">
  65. <ul class="nav navbar-nav">
  66. <li>
  67. <a href="../articles/xaringanthemer.html">Get started</a>
  68. </li>
  69. <li>
  70. <a href="../reference/index.html">Reference</a>
  71. </li>
  72. <li>
  73. <a href="../articles/themes.html">Themes</a>
  74. </li>
  75. <li>
  76. <a href="../articles/fonts.html">Fonts</a>
  77. </li>
  78. <li>
  79. <a href="../articles/template-variables.html">Template Variables</a>
  80. </li>
  81. </ul>
  82. <ul class="nav navbar-nav navbar-right">
  83. <li>
  84. <a href="../news/index.html">
  85. <span class="fa fa fa fa-newspaper-o fa-lg"></span>
  86. </a>
  87. </li>
  88. <li>
  89. <a href="https://github.com/gadenbuie/xaringanthemer">
  90. <span class="fa fa-github fa-lg"></span>
  91. </a>
  92. </li>
  93. <li>
  94. <a href="https://twitter.com/grrrck">
  95. <span class="fa fa-twitter fa-lg"></span>
  96. </a>
  97. </li>
  98. <li>
  99. <a href="https://www.garrickadenbuie.com">
  100. <span class="fa fa-home fa-lg"></span>
  101. </a>
  102. </li>
  103. </ul>
  104. </div><!--/.nav-collapse -->
  105. </div><!--/.container -->
  106. </div><!--/.navbar -->
  107. </header>
  108. <div class="row">
  109. <div class="col-md-9 contents">
  110. <div class="page-header">
  111. <h1>The ggplot2 xaringanthemer base plot theme</h1>
  112. <small class="dont-index">Source: <a href='https://github.com/gadenbuie/xaringanthemer/blob/master/R/ggplot2.R'><code>R/ggplot2.R</code></a></small>
  113. <div class="hidden name"><code>theme_xaringan_base.Rd</code></div>
  114. </div>
  115. <div class="ref-description">
  116. <p><strong>Lifecycle:</strong> <a href='https://www.tidyverse.org/lifecycle/#maturing'>Maturing</a></p>
  117. <p>Provides a base plot theme for <span class="pkg">ggplot2</span> to match the <span class="pkg">xaringan</span> slide theme
  118. created by <a href='xaringanthemer-package.html'>xaringanthemer</a>. The theme is designed to create a general plot
  119. style from two colors, a <code>background_color</code> and a <code>text_color</code> (or foreground
  120. color). Also accepts an <code>accent_color</code> and an <code>accent_secondary_color</code> that are
  121. <a href='xaringanthemer-package.html'>xaringanthemer</a> is not required for the base theme. Use
  122. <code><a href='theme_xaringan.html'>theme_xaringan()</a></code> or <code><a href='theme_xaringan_inverse.html'>theme_xaringan_inverse()</a></code> in xaringan slides styled by
  123. xaringanthemer for a plot theme that matches the slide style.</p>
  124. </div>
  125. <pre class="usage"><span class='fu'>theme_xaringan_base</span>(
  126. <span class='no'>text_color</span>,
  127. <span class='no'>background_color</span>,
  128. <span class='no'>...</span>,
  129. <span class='kw'>set_ggplot_defaults</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>,
  130. <span class='kw'>accent_color</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
  131. <span class='kw'>accent_secondary_color</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
  132. <span class='kw'>text_font</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
  133. <span class='kw'>text_font_use_google</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
  134. <span class='kw'>text_font_size</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
  135. <span class='kw'>title_font</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
  136. <span class='kw'>title_font_use_google</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
  137. <span class='kw'>title_font_size</span> <span class='kw'>=</span> <span class='kw'>NULL</span>,
  138. <span class='kw'>use_showtext</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>
  139. )</pre>
  140. <h2 class="hasAnchor" id="arguments"><a class="anchor" href="#arguments"></a>Arguments</h2>
  141. <table class="ref-arguments">
  142. <colgroup><col class="name" /><col class="desc" /></colgroup>
  143. <tr>
  144. <th>text_color</th>
  145. <td><p>Color for text and foreground</p></td>
  146. </tr>
  147. <tr>
  148. <th>background_color</th>
  149. <td><p>Color for background</p></td>
  150. </tr>
  151. <tr>
  152. <th>...</th>
  153. <td><p>Ignored</p></td>
  154. </tr>
  155. <tr>
  156. <th>set_ggplot_defaults</th>
  157. <td><p>Should defaults be set for <span class="pkg">ggplot2</span> <em>geoms</em>?
  158. Defaults to TRUE. To restore ggplot's defaults, or the previously set geom
  159. defaults, see <code><a href='theme_xaringan_set_defaults.html'>theme_xaringan_restore_defaults()</a></code>.</p></td>
  160. </tr>
  161. <tr>
  162. <th>accent_color</th>
  163. <td><p>Color for titles and accents, inherits from
  164. <code>header_color</code> or <code>text_color</code>. Used for the <code>title</code> base setting in
  165. <code><a href='https://ggplot2.tidyverse.org/reference/theme.html'>ggplot2::theme()</a></code>, and additionally for setting the <code>color</code> or <code>fill</code> of
  166. <span class="pkg">ggplot2</span> geom defaults.</p></td>
  167. </tr>
  168. <tr>
  169. <th>accent_secondary_color</th>
  170. <td><p>Color for secondary accents, inherits from
  171. <code>text_bold_color</code> or <code>accent_color</code>. Used only when setting <span class="pkg">ggplot2</span> geom
  172. defaults.</p></td>
  173. </tr>
  174. <tr>
  175. <th>text_font</th>
  176. <td><p>Font to use for text elements, passed to
  177. <code><a href='https://rdrr.io/pkg/sysfonts/man/font_add_google.html'>sysfonts::font_add_google()</a></code>, if available and <code>text_font_use_google</code> is
  178. <code>TRUE</code>. Inherits from <code>text_font_family</code>.</p></td>
  179. </tr>
  180. <tr>
  181. <th>text_font_use_google</th>
  182. <td><p>Is <code>text_font</code> available on <a href='https://fonts.google.com'>Google Fonts</a>?</p></td>
  183. </tr>
  184. <tr>
  185. <th>text_font_size</th>
  186. <td><p>Base text font size, inherits from <code>text_font_size</code>, or
  187. defaults to 11.</p></td>
  188. </tr>
  189. <tr>
  190. <th>title_font</th>
  191. <td><p>Font to use for title elements, passed to
  192. <code><a href='https://rdrr.io/pkg/sysfonts/man/font_add_google.html'>sysfonts::font_add_google()</a></code>, if available and <code>title_font_use_google</code> is
  193. <code>TRUE</code>. Inherits from <code>title_font_family</code>.</p></td>
  194. </tr>
  195. <tr>
  196. <th>title_font_use_google</th>
  197. <td><p>Is <code>title_font</code> available on <a href='https://fonts.google.com'>Google Fonts</a>?</p></td>
  198. </tr>
  199. <tr>
  200. <th>title_font_size</th>
  201. <td><p>Base text font size, inherits from <code>title_font_size</code>,
  202. or defaults to 14.</p></td>
  203. </tr>
  204. <tr>
  205. <th>use_showtext</th>
  206. <td><p>If <code>TRUE</code> (default) the <span class="pkg">showtext</span> package will be
  207. used to register Google fonts. Set to <code>FALSE</code> to disable this feature
  208. entirely, which may result in errors during plotting if the fonts used are
  209. not available locally.</p></td>
  210. </tr>
  211. </table>
  212. <h2 class="hasAnchor" id="value"><a class="anchor" href="#value"></a>Value</h2>
  213. <p>A ggplot2 theme</p>
  214. <h2 class="hasAnchor" id="see-also"><a class="anchor" href="#see-also"></a>See also</h2>
  215. <div class='dont-index'><p>Other xaringanthemer ggplot2 themes:
  216. <code><a href='theme_xaringan_inverse.html'>theme_xaringan_inverse</a>()</code>,
  217. <code><a href='theme_xaringan_set_defaults.html'>theme_xaringan_set_defaults</a>()</code>,
  218. <code><a href='theme_xaringan.html'>theme_xaringan</a>()</code></p></div>
  219. <h2 class="hasAnchor" id="examples"><a class="anchor" href="#examples"></a>Examples</h2>
  220. <pre class="examples"><div class='input'><span class='co'># Requires ggplot2</span>
  221. <span class='no'>has_ggplot2</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://rdrr.io/r/base/ns-load.html'>requireNamespace</a></span>(<span class='st'>"ggplot2"</span>, <span class='kw'>quietly</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>)
  222. <span class='kw'>if</span> (<span class='no'>has_ggplot2</span>) {
  223. <span class='fu'><a href='https://rdrr.io/r/base/library.html'>library</a></span>(<span class='no'>ggplot2</span>)
  224. <span class='no'>plot1</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot</a></span>(<span class='no'>iris</span>) +
  225. <span class='fu'><a href='https://ggplot2.tidyverse.org/reference/aes.html'>aes</a></span>(<span class='no'>Petal.Length</span>, <span class='no'>Petal.Width</span>) +
  226. <span class='fu'><a href='https://ggplot2.tidyverse.org/reference/geom_point.html'>geom_point</a></span>() +
  227. <span class='fu'>theme_xaringan_base</span>(
  228. <span class='kw'>text_color</span> <span class='kw'>=</span> <span class='st'>"#602f6b"</span>, <span class='co'># imperial</span>
  229. <span class='kw'>background_color</span> <span class='kw'>=</span> <span class='st'>"#f8f8f8"</span>, <span class='co'># light gray</span>
  230. <span class='kw'>accent_color</span> <span class='kw'>=</span> <span class='st'>"#317873"</span>, <span class='co'># myrtle green</span>
  231. <span class='kw'>title_font</span> <span class='kw'>=</span> <span class='st'>"sans"</span>,
  232. <span class='kw'>text_font</span> <span class='kw'>=</span> <span class='st'>"serif"</span>,
  233. <span class='kw'>set_ggplot_defaults</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>
  234. ) +
  235. <span class='fu'><a href='https://ggplot2.tidyverse.org/reference/labs.html'>labs</a></span>(
  236. <span class='kw'>title</span> <span class='kw'>=</span> <span class='st'>"Basic Iris Plot"</span>,
  237. <span class='kw'>subtitle</span> <span class='kw'>=</span> <span class='st'>"+ theme_xaringan_base()"</span>,
  238. <span class='kw'>caption</span> <span class='kw'>=</span> <span class='st'>"xaringanthemer"</span>
  239. )
  240. <span class='fu'><a href='https://rdrr.io/r/base/print.html'>print</a></span>(<span class='no'>plot1</span>)
  241. <span class='no'>plot2</span> <span class='kw'>&lt;-</span> <span class='fu'><a href='https://ggplot2.tidyverse.org/reference/ggplot.html'>ggplot</a></span>(<span class='no'>iris</span>) +
  242. <span class='fu'><a href='https://ggplot2.tidyverse.org/reference/aes.html'>aes</a></span>(<span class='no'>Sepal.Width</span>) +
  243. <span class='fu'><a href='https://ggplot2.tidyverse.org/reference/geom_histogram.html'>geom_histogram</a></span>(<span class='kw'>binwidth</span> <span class='kw'>=</span> <span class='fl'>0.1</span>) +
  244. <span class='fu'>theme_xaringan_base</span>(
  245. <span class='kw'>text_color</span> <span class='kw'>=</span> <span class='st'>"#a8a9c8"</span>, <span class='co'># light purple</span>
  246. <span class='kw'>background_color</span> <span class='kw'>=</span> <span class='st'>"#303163"</span>, <span class='co'># deep slate purple</span>
  247. <span class='kw'>accent_color</span> <span class='kw'>=</span> <span class='st'>"#ffff99"</span>, <span class='co'># canary yellow</span>
  248. <span class='kw'>title_font</span> <span class='kw'>=</span> <span class='st'>"sans"</span>,
  249. <span class='kw'>text_font</span> <span class='kw'>=</span> <span class='st'>"serif"</span>,
  250. <span class='kw'>set_ggplot_defaults</span> <span class='kw'>=</span> <span class='fl'>TRUE</span>
  251. ) +
  252. <span class='fu'><a href='https://ggplot2.tidyverse.org/reference/labs.html'>labs</a></span>(
  253. <span class='kw'>title</span> <span class='kw'>=</span> <span class='st'>"Basic Iris Plot"</span>,
  254. <span class='kw'>subtitle</span> <span class='kw'>=</span> <span class='st'>"+ theme_xaringan_base()"</span>,
  255. <span class='kw'>caption</span> <span class='kw'>=</span> <span class='st'>"xaringanthemer"</span>
  256. )
  257. <span class='fu'><a href='https://rdrr.io/r/base/print.html'>print</a></span>(<span class='no'>plot2</span>)
  258. }</div><div class='img'><img src='theme_xaringan_base-1.png' alt='' width='700' height='433' /></div><div class='img'><img src='theme_xaringan_base-2.png' alt='' width='700' height='433' /></div></pre>
  259. </div>
  260. <div class="col-md-3 hidden-xs hidden-sm" id="pkgdown-sidebar">
  261. <nav id="toc" data-toggle="toc" class="sticky-top">
  262. <h2 data-toc-skip>Contents</h2>
  263. </nav>
  264. </div>
  265. </div>
  266. <footer>
  267. <div class="copyright">
  268. <p>Developed by <a href='https://www.garrickadenbuie.com'>Garrick Aden-Buie</a>.</p>
  269. </div>
  270. <div class="pkgdown">
  271. <p>Site built with <a href="https://pkgdown.r-lib.org/">pkgdown</a> 1.5.0.</p>
  272. </div>
  273. </footer>
  274. </div>
  275. </body>
  276. </html>