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

375 lines
20KB

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