EVOLUTION-MANAGER
Edit File: scale_date.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 date/time data</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_date {ggplot2}"><tr><td>scale_date {ggplot2}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Position scales for date/time data</h2> <h3>Description</h3> <p>These are the default scales for the three date/time class. These will usually be added automatically. To override manually, use <code style="white-space: pre;">scale_*_date</code> for dates (class <code>Date</code>), <code style="white-space: pre;">scale_*_datetime</code> for datetimes (class <code>POSIXct</code>), and <code style="white-space: pre;">scale_*_time</code> for times (class <code>hms</code>). </p> <h3>Usage</h3> <pre> scale_x_date( name = waiver(), breaks = waiver(), date_breaks = waiver(), labels = waiver(), date_labels = waiver(), minor_breaks = waiver(), date_minor_breaks = waiver(), limits = NULL, expand = waiver(), guide = waiver(), position = "bottom", sec.axis = waiver() ) scale_y_date( name = waiver(), breaks = waiver(), date_breaks = waiver(), labels = waiver(), date_labels = waiver(), minor_breaks = waiver(), date_minor_breaks = waiver(), limits = NULL, expand = waiver(), guide = waiver(), position = "left", sec.axis = waiver() ) scale_x_datetime( name = waiver(), breaks = waiver(), date_breaks = waiver(), labels = waiver(), date_labels = waiver(), minor_breaks = waiver(), date_minor_breaks = waiver(), timezone = NULL, limits = NULL, expand = waiver(), guide = waiver(), position = "bottom", sec.axis = waiver() ) scale_y_datetime( name = waiver(), breaks = waiver(), date_breaks = waiver(), labels = waiver(), date_labels = waiver(), minor_breaks = waiver(), date_minor_breaks = waiver(), timezone = NULL, limits = NULL, expand = waiver(), guide = waiver(), position = "left", sec.axis = waiver() ) scale_x_time( name = waiver(), breaks = waiver(), minor_breaks = waiver(), labels = waiver(), limits = NULL, expand = waiver(), oob = censor, na.value = NA_real_, guide = waiver(), position = "bottom", sec.axis = waiver() ) scale_y_time( name = waiver(), breaks = waiver(), minor_breaks = waiver(), labels = waiver(), limits = NULL, expand = waiver(), oob = censor, na.value = NA_real_, guide = waiver(), position = "left", sec.axis = waiver() ) </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 breaks specified by <code>date_breaks</code> </p> </li> <li><p> A <code>Date</code>/<code>POSIXct</code> vector giving positions of breaks </p> </li> <li><p> A function that takes the limits as input and returns breaks as output </p> </li></ul> </td></tr> <tr valign="top"><td><code>date_breaks</code></td> <td> <p>A string giving the distance between breaks like "2 weeks", or "10 years". If both <code>breaks</code> and <code>date_breaks</code> are specified, <code>date_breaks</code> wins.</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>date_labels</code></td> <td> <p>A string giving the formatting specification for the labels. Codes are defined in <code><a href="../../base/html/strptime.html">strftime()</a></code>. If both <code>labels</code> and <code>date_labels</code> are specified, <code>date_labels</code> wins.</p> </td></tr> <tr valign="top"><td><code>minor_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 breaks specified by <code>date_minor_breaks</code> </p> </li> <li><p> A <code>Date</code>/<code>POSIXct</code> vector giving positions of minor breaks </p> </li> <li><p> A function that takes the limits as input and returns minor breaks as output </p> </li></ul> </td></tr> <tr valign="top"><td><code>date_minor_breaks</code></td> <td> <p>A string giving the distance between minor breaks like "2 weeks", or "10 years". If both <code>minor_breaks</code> and <code>date_minor_breaks</code> are specified, <code>date_minor_breaks</code> wins.</p> </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>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>timezone</code></td> <td> <p>The timezone to use for display on the axes. The default (<code>NULL</code>) uses the timezone encoded in the data.</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> </table> <h3>See Also</h3> <p><code><a href="sec_axis.html">sec_axis()</a></code> for how to specify secondary axes </p> <p>Other position scales: <code><a href="scale_binned.html">scale_x_binned</a>()</code>, <code><a href="scale_continuous.html">scale_x_continuous</a>()</code>, <code><a href="scale_discrete.html">scale_x_discrete</a>()</code> </p> <h3>Examples</h3> <pre> last_month <- Sys.Date() - 0:29 df <- data.frame( date = last_month, price = runif(30) ) base <- ggplot(df, aes(date, price)) + geom_line() # The date scale will attempt to pick sensible defaults for # major and minor tick marks. Override with date_breaks, date_labels # date_minor_breaks arguments. base + scale_x_date(date_labels = "%b %d") base + scale_x_date(date_breaks = "1 week", date_labels = "%W") base + scale_x_date(date_minor_breaks = "1 day") # Set limits base + scale_x_date(limits = c(Sys.Date() - 7, NA)) </pre> <hr /><div style="text-align: center;">[Package <em>ggplot2</em> version 3.3.2 <a href="00Index.html">Index</a>]</div> </body></html>