😎 Give your xaringan slides some style
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

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