😎 Give your xaringan slides some style
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

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