EVOLUTION-MANAGER
Edit File: scale_continuous.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: Position scales for 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_continuous {ggplot2}"><tr><td>scale_continuous {ggplot2}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Position scales for continuous data (x & y)</h2> <h3>Description</h3> <p><code>scale_x_continuous()</code> and <code>scale_y_continuous()</code> are the default scales for continuous x and y aesthetics. There are three variants that set the <code>trans</code> argument for commonly used transformations: <code style="white-space: pre;">scale_*_log10()</code>, <code style="white-space: pre;">scale_*_sqrt()</code> and <code style="white-space: pre;">scale_*_reverse()</code>. </p> <h3>Usage</h3> <pre> scale_x_continuous( name = waiver(), breaks = waiver(), minor_breaks = waiver(), n.breaks = NULL, labels = waiver(), limits = NULL, expand = waiver(), oob = censor, na.value = NA_real_, trans = "identity", guide = waiver(), position = "bottom", sec.axis = waiver() ) scale_y_continuous( name = waiver(), breaks = waiver(), minor_breaks = waiver(), n.breaks = NULL, labels = waiver(), limits = NULL, expand = waiver(), oob = censor, na.value = NA_real_, trans = "identity", guide = waiver(), position = "left", sec.axis = waiver() ) scale_x_log10(...) scale_y_log10(...) scale_x_reverse(...) scale_y_reverse(...) scale_x_sqrt(...) scale_y_sqrt(...) </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>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>minor_breaks</code></td> <td> <p>One of: </p> <ul> <li> <p><code>NULL</code> for no minor breaks </p> </li> <li> <p><code>waiver()</code> for the default breaks (one minor break between each major break) </p> </li> <li><p> A numeric vector of positions </p> </li> <li><p> A function that given the limits returns a vector of minor breaks. </p> </li></ul> </td></tr> <tr valign="top"><td><code>n.breaks</code></td> <td> <p>An integer guiding the number of major breaks. The algorithm may choose a slightly different number to ensure nice break labels. Will only have an effect if <code>breaks = waiver()</code>. Use <code>NULL</code> to use the default number of breaks given by the transformation.</p> </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>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> <tr valign="top"><td><code>sec.axis</code></td> <td> <p><code><a href="sec_axis.html">sec_axis()</a></code> is used to specify a secondary axis.</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>Other arguments passed on to <code style="white-space: pre;">scale_(x|y)_continuous()</code></p> </td></tr> </table> <h3>Details</h3> <p>For simple manipulation of labels and limits, you may wish to use <code><a href="labs.html">labs()</a></code> and <code><a href="lims.html">lims()</a></code> instead. </p> <h3>See Also</h3> <p>Other position scales: <code><a href="scale_binned.html">scale_x_binned</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> p1 <- ggplot(mpg, aes(displ, hwy)) + geom_point() p1 # Manipulating the default position scales lets you: # * change the axis labels p1 + scale_x_continuous("Engine displacement (L)") + scale_y_continuous("Highway MPG") # You can also use the short-cut labs(). # Use NULL to suppress axis labels p1 + labs(x = NULL, y = NULL) # * modify the axis limits p1 + scale_x_continuous(limits = c(2, 6)) p1 + scale_x_continuous(limits = c(0, 10)) # you can also use the short hand functions `xlim()` and `ylim()` p1 + xlim(2, 6) # * choose where the ticks appear p1 + scale_x_continuous(breaks = c(2, 4, 6)) # * choose your own labels p1 + scale_x_continuous( breaks = c(2, 4, 6), label = c("two", "four", "six") ) # Typically you'll pass a function to the `labels` argument. # Some common formats are built into the scales package: df <- data.frame( x = rnorm(10) * 100000, y = seq(0, 1, length.out = 10) ) p2 <- ggplot(df, aes(x, y)) + geom_point() p2 + scale_y_continuous(labels = scales::percent) p2 + scale_y_continuous(labels = scales::dollar) p2 + scale_x_continuous(labels = scales::comma) # You can also override the default linear mapping by using a # transformation. There are three shortcuts: p1 + scale_y_log10() p1 + scale_y_sqrt() p1 + scale_y_reverse() # Or you can supply a transformation in the `trans` argument: p1 + scale_y_continuous(trans = scales::reciprocal_trans()) # You can also create your own. See ?scales::trans_new </pre> <hr /><div style="text-align: center;">[Package <em>ggplot2</em> version 3.3.2 <a href="00Index.html">Index</a>]</div> </body></html>