EVOLUTION-MANAGER
Edit File: geom_dotplot.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: Dot 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 geom_dotplot {ggplot2}"><tr><td>geom_dotplot {ggplot2}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Dot plot</h2> <h3>Description</h3> <p>In a dot plot, the width of a dot corresponds to the bin width (or maximum width, depending on the binning algorithm), and dots are stacked, with each dot representing one observation. </p> <h3>Usage</h3> <pre> geom_dotplot( mapping = NULL, data = NULL, position = "identity", ..., binwidth = NULL, binaxis = "x", method = "dotdensity", binpositions = "bygroup", stackdir = "up", stackratio = 1, dotsize = 1, stackgroups = FALSE, origin = NULL, right = TRUE, width = 0.9, drop = FALSE, na.rm = FALSE, show.legend = NA, inherit.aes = TRUE ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>mapping</code></td> <td> <p>Set of aesthetic mappings created by <code><a href="aes.html">aes()</a></code> or <code><a href="aes_.html">aes_()</a></code>. If specified and <code>inherit.aes = TRUE</code> (the default), it is combined with the default mapping at the top level of the plot. You must supply <code>mapping</code> if there is no plot mapping.</p> </td></tr> <tr valign="top"><td><code>data</code></td> <td> <p>The data to be displayed in this layer. There are three options: </p> <p>If <code>NULL</code>, the default, the data is inherited from the plot data as specified in the call to <code><a href="ggplot.html">ggplot()</a></code>. </p> <p>A <code>data.frame</code>, or other object, will override the plot data. All objects will be fortified to produce a data frame. See <code><a href="fortify.html">fortify()</a></code> for which variables will be created. </p> <p>A <code>function</code> will be called with a single argument, the plot data. The return value must be a <code>data.frame</code>, and will be used as the layer data. A <code>function</code> can be created from a <code>formula</code> (e.g. <code>~ head(.x, 10)</code>).</p> </td></tr> <tr valign="top"><td><code>position</code></td> <td> <p>Position adjustment, either as a string, or the result of a call to a position adjustment function.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Other arguments passed on to <code><a href="layer.html">layer()</a></code>. These are often aesthetics, used to set an aesthetic to a fixed value, like <code>colour = "red"</code> or <code>size = 3</code>. They may also be parameters to the paired geom/stat.</p> </td></tr> <tr valign="top"><td><code>binwidth</code></td> <td> <p>When <code>method</code> is "dotdensity", this specifies maximum bin width. When <code>method</code> is "histodot", this specifies bin width. Defaults to 1/30 of the range of the data</p> </td></tr> <tr valign="top"><td><code>binaxis</code></td> <td> <p>The axis to bin along, "x" (default) or "y"</p> </td></tr> <tr valign="top"><td><code>method</code></td> <td> <p>"dotdensity" (default) for dot-density binning, or "histodot" for fixed bin widths (like stat_bin)</p> </td></tr> <tr valign="top"><td><code>binpositions</code></td> <td> <p>When <code>method</code> is "dotdensity", "bygroup" (default) determines positions of the bins for each group separately. "all" determines positions of the bins with all the data taken together; this is used for aligning dot stacks across multiple groups.</p> </td></tr> <tr valign="top"><td><code>stackdir</code></td> <td> <p>which direction to stack the dots. "up" (default), "down", "center", "centerwhole" (centered, but with dots aligned)</p> </td></tr> <tr valign="top"><td><code>stackratio</code></td> <td> <p>how close to stack the dots. Default is 1, where dots just touch. Use smaller values for closer, overlapping dots.</p> </td></tr> <tr valign="top"><td><code>dotsize</code></td> <td> <p>The diameter of the dots relative to <code>binwidth</code>, default 1.</p> </td></tr> <tr valign="top"><td><code>stackgroups</code></td> <td> <p>should dots be stacked across groups? This has the effect that <code>position = "stack"</code> should have, but can't (because this geom has some odd properties).</p> </td></tr> <tr valign="top"><td><code>origin</code></td> <td> <p>When <code>method</code> is "histodot", origin of first bin</p> </td></tr> <tr valign="top"><td><code>right</code></td> <td> <p>When <code>method</code> is "histodot", should intervals be closed on the right (a, b], or not [a, b)</p> </td></tr> <tr valign="top"><td><code>width</code></td> <td> <p>When <code>binaxis</code> is "y", the spacing of the dot stacks for dodging.</p> </td></tr> <tr valign="top"><td><code>drop</code></td> <td> <p>If TRUE, remove all bins with zero counts</p> </td></tr> <tr valign="top"><td><code>na.rm</code></td> <td> <p>If <code>FALSE</code>, the default, missing values are removed with a warning. If <code>TRUE</code>, missing values are silently removed.</p> </td></tr> <tr valign="top"><td><code>show.legend</code></td> <td> <p>logical. Should this layer be included in the legends? <code>NA</code>, the default, includes if any aesthetics are mapped. <code>FALSE</code> never includes, and <code>TRUE</code> always includes. It can also be a named logical vector to finely select the aesthetics to display.</p> </td></tr> <tr valign="top"><td><code>inherit.aes</code></td> <td> <p>If <code>FALSE</code>, overrides the default aesthetics, rather than combining with them. This is most useful for helper functions that define both data and aesthetics and shouldn't inherit behaviour from the default plot specification, e.g. <code><a href="borders.html">borders()</a></code>.</p> </td></tr> </table> <h3>Details</h3> <p>There are two basic approaches: <em>dot-density</em> and <em>histodot</em>. With dot-density binning, the bin positions are determined by the data and <code>binwidth</code>, which is the maximum width of each bin. See Wilkinson (1999) for details on the dot-density binning algorithm. With histodot binning, the bins have fixed positions and fixed widths, much like a histogram. </p> <p>When binning along the x axis and stacking along the y axis, the numbers on y axis are not meaningful, due to technical limitations of ggplot2. You can hide the y axis, as in one of the examples, or manually scale it to match the number of dots. </p> <h3>Aesthetics</h3> <p><code>geom_dotplot()</code> understands the following aesthetics (required aesthetics are in bold): </p> <ul> <li> <p><strong><code>x</code></strong> </p> </li> <li> <p><strong><code>y</code></strong> </p> </li> <li> <p><code>alpha</code> </p> </li> <li> <p><code>colour</code> </p> </li> <li> <p><code>fill</code> </p> </li> <li> <p><code>group</code> </p> </li> <li> <p><code>linetype</code> </p> </li> <li> <p><code>stroke</code> </p> </li></ul> <p>Learn more about setting these aesthetics in <code>vignette("ggplot2-specs")</code>. </p> <h3>Computed variables</h3> <dl> <dt>x</dt><dd><p>center of each bin, if binaxis is "x"</p> </dd> <dt>y</dt><dd><p>center of each bin, if binaxis is "x"</p> </dd> <dt>binwidth</dt><dd><p>max width of each bin if method is "dotdensity"; width of each bin if method is "histodot"</p> </dd> <dt>count</dt><dd><p>number of points in bin</p> </dd> <dt>ncount</dt><dd><p>count, scaled to maximum of 1</p> </dd> <dt>density</dt><dd><p>density of points in bin, scaled to integrate to 1, if method is "histodot"</p> </dd> <dt>ndensity</dt><dd><p>density, scaled to maximum of 1, if method is "histodot"</p> </dd> </dl> <h3>References</h3> <p>Wilkinson, L. (1999) Dot plots. The American Statistician, 53(3), 276-281. </p> <h3>Examples</h3> <pre> ggplot(mtcars, aes(x = mpg)) + geom_dotplot() ggplot(mtcars, aes(x = mpg)) + geom_dotplot(binwidth = 1.5) # Use fixed-width bins ggplot(mtcars, aes(x = mpg)) + geom_dotplot(method="histodot", binwidth = 1.5) # Some other stacking methods ggplot(mtcars, aes(x = mpg)) + geom_dotplot(binwidth = 1.5, stackdir = "center") ggplot(mtcars, aes(x = mpg)) + geom_dotplot(binwidth = 1.5, stackdir = "centerwhole") # y axis isn't really meaningful, so hide it ggplot(mtcars, aes(x = mpg)) + geom_dotplot(binwidth = 1.5) + scale_y_continuous(NULL, breaks = NULL) # Overlap dots vertically ggplot(mtcars, aes(x = mpg)) + geom_dotplot(binwidth = 1.5, stackratio = .7) # Expand dot diameter ggplot(mtcars, aes(x = mpg)) + geom_dotplot(binwidth = 1.5, dotsize = 1.25) # Change dot fill colour, stroke width ggplot(mtcars, aes(x = mpg)) + geom_dotplot(binwidth = 1.5, fill = "white", stroke = 2) # Examples with stacking along y axis instead of x ggplot(mtcars, aes(x = 1, y = mpg)) + geom_dotplot(binaxis = "y", stackdir = "center") ggplot(mtcars, aes(x = factor(cyl), y = mpg)) + geom_dotplot(binaxis = "y", stackdir = "center") ggplot(mtcars, aes(x = factor(cyl), y = mpg)) + geom_dotplot(binaxis = "y", stackdir = "centerwhole") ggplot(mtcars, aes(x = factor(vs), fill = factor(cyl), y = mpg)) + geom_dotplot(binaxis = "y", stackdir = "center", position = "dodge") # binpositions="all" ensures that the bins are aligned between groups ggplot(mtcars, aes(x = factor(am), y = mpg)) + geom_dotplot(binaxis = "y", stackdir = "center", binpositions="all") # Stacking multiple groups, with different fill ggplot(mtcars, aes(x = mpg, fill = factor(cyl))) + geom_dotplot(stackgroups = TRUE, binwidth = 1, binpositions = "all") ggplot(mtcars, aes(x = mpg, fill = factor(cyl))) + geom_dotplot(stackgroups = TRUE, binwidth = 1, method = "histodot") ggplot(mtcars, aes(x = 1, y = mpg, fill = factor(cyl))) + geom_dotplot(binaxis = "y", stackgroups = TRUE, binwidth = 1, method = "histodot") </pre> <hr /><div style="text-align: center;">[Package <em>ggplot2</em> version 3.3.2 <a href="00Index.html">Index</a>]</div> </body></html>