EVOLUTION-MANAGER
Edit File: scale_binned.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: Positional scales for binning continuous data (x & y)</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 scale_binned {ggplot2}"><tr><td>scale_binned {ggplot2}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Positional scales for binning continuous data (x & y)</h2> <h3>Description</h3> <p><code>scale_x_binned()</code> and <code>scale_y_binned()</code> are scales that discretize continuous position data. You can use these scales to transform continuous inputs before using it with a geom that requires discrete positions. An example is using <code>scale_x_binned()</code> with <code><a href="geom_bar.html">geom_bar()</a></code> to create a histogram. </p> <h3>Usage</h3> <pre> scale_x_binned( name = waiver(), n.breaks = 10, nice.breaks = TRUE, breaks = waiver(), labels = waiver(), limits = NULL, expand = waiver(), oob = squish, na.value = NA_real_, right = TRUE, show.limits = FALSE, trans = "identity", guide = waiver(), position = "bottom" ) scale_y_binned( name = waiver(), n.breaks = 10, nice.breaks = TRUE, breaks = waiver(), labels = waiver(), limits = NULL, expand = waiver(), oob = squish, na.value = NA_real_, right = TRUE, show.limits = FALSE, trans = "identity", guide = waiver(), position = "left" ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>name</code></td> <td> <p>The name of the scale. Used as the axis or legend title. If <code>waiver()</code>, the default, the name of the scale is taken from the first mapping used for that aesthetic. If <code>NULL</code>, the legend title will be omitted.</p> </td></tr> <tr valign="top"><td><code>n.breaks</code></td> <td> <p>The number of break points to create if breaks are not given directly.</p> </td></tr> <tr valign="top"><td><code>nice.breaks</code></td> <td> <p>Logical. Should breaks be attempted placed at nice values instead of exactly evenly spaced between the limits. If <code>TRUE</code> (default) the scale will ask the transformation object to create breaks, and this may result in a different number of breaks than requested. Ignored if breaks are given explicetly.</p> </td></tr> <tr valign="top"><td><code>breaks</code></td> <td> <p>One of: </p> <ul> <li> <p><code>NULL</code> for no breaks </p> </li> <li> <p><code>waiver()</code> for the default breaks computed by the <a href="../../scales/html/trans_new.html">transformation object</a> </p> </li> <li><p> A numeric vector of positions </p> </li> <li><p> A function that takes the limits as input and returns breaks as output (e.g., a function returned by <code><a href="../../scales/html/breaks_extended.html">scales::extended_breaks()</a></code>) </p> </li></ul> </td></tr> <tr valign="top"><td><code>labels</code></td> <td> <p>One of: </p> <ul> <li> <p><code>NULL</code> for no labels </p> </li> <li> <p><code>waiver()</code> for the default labels computed by the transformation object </p> </li> <li><p> A character vector giving labels (must be same length as <code>breaks</code>) </p> </li> <li><p> A function that takes the breaks as input and returns labels as output </p> </li></ul> </td></tr> <tr valign="top"><td><code>limits</code></td> <td> <p>One of: </p> <ul> <li> <p><code>NULL</code> to use the default scale range </p> </li> <li><p> A numeric vector of length two providing limits of the scale. Use <code>NA</code> to refer to the existing minimum or maximum </p> </li> <li><p> A function that accepts the existing (automatic) limits and returns new limits Note that setting limits on positional scales will <strong>remove</strong> data outside of the limits. If the purpose is to zoom, use the limit argument in the coordinate system (see <code><a href="coord_cartesian.html">coord_cartesian()</a></code>). </p> </li></ul> </td></tr> <tr valign="top"><td><code>expand</code></td> <td> <p>For position scales, a vector of range expansion constants used to add some padding around the data to ensure that they are placed some distance away from the axes. Use the convenience function <code><a href="expansion.html">expansion()</a></code> to generate the values for the <code>expand</code> argument. The defaults are to expand the scale by 5% on each side for continuous variables, and by 0.6 units on each side for discrete variables.</p> </td></tr> <tr valign="top"><td><code>oob</code></td> <td> <p>One of: </p> <ul> <li><p> Function that handles limits outside of the scale limits (out of bounds). </p> </li> <li><p> The default (<code><a href="../../scales/html/oob.html">scales::censor()</a></code>) replaces out of bounds values with <code>NA</code>. </p> </li> <li> <p><code><a href="../../scales/html/oob.html">scales::squish()</a></code> for squishing out of bounds values into range. </p> </li> <li> <p><code><a href="../../scales/html/oob.html">scales::squish_infinite()</a></code> for squishing infinite values into range. </p> </li></ul> </td></tr> <tr valign="top"><td><code>na.value</code></td> <td> <p>Missing values will be replaced with this value.</p> </td></tr> <tr valign="top"><td><code>right</code></td> <td> <p>Should values on the border between bins be part of the right (upper) bin?</p> </td></tr> <tr valign="top"><td><code>show.limits</code></td> <td> <p>should the limits of the scale appear as ticks</p> </td></tr> <tr valign="top"><td><code>trans</code></td> <td> <p>For continuous scales, the name of a transformation object or the object itself. Built-in transformations include "asn", "atanh", "boxcox", "date", "exp", "hms", "identity", "log", "log10", "log1p", "log2", "logit", "modulus", "probability", "probit", "pseudo_log", "reciprocal", "reverse", "sqrt" and "time". </p> <p>A transformation object bundles together a transform, its inverse, and methods for generating breaks and labels. Transformation objects are defined in the scales package, and are called <code style="white-space: pre;"><name>_trans</code> (e.g., <code><a href="../../scales/html/boxcox_trans.html">scales::boxcox_trans()</a></code>). You can create your own transformation with <code><a href="../../scales/html/trans_new.html">scales::trans_new()</a></code>.</p> </td></tr> <tr valign="top"><td><code>guide</code></td> <td> <p>A function used to create a guide or its name. See <code><a href="guides.html">guides()</a></code> for more information.</p> </td></tr> <tr valign="top"><td><code>position</code></td> <td> <p>For position scales, The position of the axis. <code>left</code> or <code>right</code> for y axes, <code>top</code> or <code>bottom</code> for x axes.</p> </td></tr> </table> <h3>See Also</h3> <p>Other position scales: <code><a href="scale_continuous.html">scale_x_continuous</a>()</code>, <code><a href="scale_date.html">scale_x_date</a>()</code>, <code><a href="scale_discrete.html">scale_x_discrete</a>()</code> </p> <h3>Examples</h3> <pre> # Create a histogram by binning the x-axis ggplot(mtcars) + geom_bar(aes(mpg)) + scale_x_binned() </pre> <hr /><div style="text-align: center;">[Package <em>ggplot2</em> version 3.3.2 <a href="00Index.html">Index</a>]</div> </body></html>