EVOLUTION-MANAGER
Edit File: coord_trans.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: Transformed Cartesian coordinate system</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 coord_trans {ggplot2}"><tr><td>coord_trans {ggplot2}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Transformed Cartesian coordinate system</h2> <h3>Description</h3> <p><code>coord_trans()</code> is different to scale transformations in that it occurs after statistical transformation and will affect the visual appearance of geoms - there is no guarantee that straight lines will continue to be straight. </p> <h3>Usage</h3> <pre> coord_trans( x = "identity", y = "identity", xlim = NULL, ylim = NULL, limx = "DEPRECATED", limy = "DEPRECATED", clip = "on", expand = TRUE ) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>x, y</code></td> <td> <p>Transformers for x and y axes or their names.</p> </td></tr> <tr valign="top"><td><code>xlim</code></td> <td> <p>Limits for the x and y axes.</p> </td></tr> <tr valign="top"><td><code>ylim</code></td> <td> <p>Limits for the x and y axes.</p> </td></tr> <tr valign="top"><td><code>limx, limy</code></td> <td> <p><strong>Deprecated</strong>: use <code>xlim</code> and <code>ylim</code> instead.</p> </td></tr> <tr valign="top"><td><code>clip</code></td> <td> <p>Should drawing be clipped to the extent of the plot panel? A setting of <code>"on"</code> (the default) means yes, and a setting of <code>"off"</code> means no. In most cases, the default of <code>"on"</code> should not be changed, as setting <code>clip = "off"</code> can cause unexpected results. It allows drawing of data points anywhere on the plot, including in the plot margins. If limits are set via <code>xlim</code> and <code>ylim</code> and some data points fall outside those limits, then those data points may show up in places such as the axes, the legend, the plot title, or the plot margins.</p> </td></tr> <tr valign="top"><td><code>expand</code></td> <td> <p>If <code>TRUE</code>, the default, adds a small expansion factor to the limits to ensure that data and axes don't overlap. If <code>FALSE</code>, limits are taken exactly from the data or <code>xlim</code>/<code>ylim</code>.</p> </td></tr> </table> <h3>Details</h3> <p>Transformations only work with continuous values: see <code><a href="../../scales/html/trans_new.html">scales::trans_new()</a></code> for list of transformations, and instructions on how to create your own. </p> <h3>Examples</h3> <pre> # See ?geom_boxplot for other examples # Three ways of doing transformation in ggplot: # * by transforming the data ggplot(diamonds, aes(log10(carat), log10(price))) + geom_point() # * by transforming the scales ggplot(diamonds, aes(carat, price)) + geom_point() + scale_x_log10() + scale_y_log10() # * by transforming the coordinate system: ggplot(diamonds, aes(carat, price)) + geom_point() + coord_trans(x = "log10", y = "log10") # The difference between transforming the scales and # transforming the coordinate system is that scale # transformation occurs BEFORE statistics, and coordinate # transformation afterwards. Coordinate transformation also # changes the shape of geoms: d <- subset(diamonds, carat > 0.5) ggplot(d, aes(carat, price)) + geom_point() + geom_smooth(method = "lm") + scale_x_log10() + scale_y_log10() ggplot(d, aes(carat, price)) + geom_point() + geom_smooth(method = "lm") + coord_trans(x = "log10", y = "log10") # Here I used a subset of diamonds so that the smoothed line didn't # drop below zero, which obviously causes problems on the log-transformed # scale # With a combination of scale and coordinate transformation, it's # possible to do back-transformations: ggplot(diamonds, aes(carat, price)) + geom_point() + geom_smooth(method = "lm") + scale_x_log10() + scale_y_log10() + coord_trans(x = scales::exp_trans(10), y = scales::exp_trans(10)) # cf. ggplot(diamonds, aes(carat, price)) + geom_point() + geom_smooth(method = "lm") # Also works with discrete scales df <- data.frame(a = abs(rnorm(26)),letters) plot <- ggplot(df,aes(a,letters)) + geom_point() plot + coord_trans(x = "log10") plot + coord_trans(x = "sqrt") </pre> <hr /><div style="text-align: center;">[Package <em>ggplot2</em> version 3.3.2 <a href="00Index.html">Index</a>]</div> </body></html>