😎 Give your xaringan slides some style
No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

344 líneas
17KB

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