EVOLUTION-MANAGER
Edit File: gg-add.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Add components to a plot</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for +.gg {ggplot2}"><tr><td>+.gg {ggplot2}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Add components to a plot</h2> <h3>Description</h3> <p><code>+</code> is the key to constructing sophisticated ggplot2 graphics. It allows you to start simple, then get more and more complex, checking your work at each step. </p> <h3>Usage</h3> <pre> ## S3 method for class 'gg' e1 + e2 e1 %+% e2 </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>e1</code></td> <td> <p>An object of class <code><a href="ggplot.html">ggplot()</a></code> or a <code><a href="theme.html">theme()</a></code>.</p> </td></tr> <tr valign="top"><td><code>e2</code></td> <td> <p>A plot component, as described below.</p> </td></tr> </table> <h3>What can you add?</h3> <p>You can add any of the following types of objects: </p> <ul> <li><p> An <code><a href="aes.html">aes()</a></code> object replaces the default aesthetics. </p> </li> <li><p> A layer created by a <code>geom_</code> or <code>stat_</code> function adds a new layer. </p> </li> <li><p> A <code>scale</code> overrides the existing scale. </p> </li> <li><p> A <code><a href="theme.html">theme()</a></code> modifies the current theme. </p> </li> <li><p> A <code>coord</code> overrides the current coordinate system. </p> </li> <li><p> A <code>facet</code> specification overrides the current faceting. </p> </li></ul> <p>To replace the current default data frame, you must use <code style="white-space: pre;">%+%</code>, due to S3 method precedence issues. </p> <p>You can also supply a list, in which case each element of the list will be added in turn. </p> <h3>See Also</h3> <p><code><a href="theme.html">theme()</a></code> </p> <h3>Examples</h3> <pre> base <- ggplot(mpg, aes(displ, hwy)) + geom_point() base + geom_smooth() # To override the data, you must use %+% base %+% subset(mpg, fl == "p") # Alternatively, you can add multiple components with a list. # This can be useful to return from a function. base + list(subset(mpg, fl == "p"), geom_smooth()) </pre> <hr /><div style="text-align: center;">[Package <em>ggplot2</em> version 3.3.2 <a href="00Index.html">Index</a>]</div> </body></html>