geom_abs_text | R Documentation |
geom_abs_text
functions similarly to ggplot2's geom_text
, except that instead of taking x
and y
aesthetics, it requires xpos
and ypos
aesthetics, values from 0-1 that determine the absolute x
and y
coordinates with respect to whatever viewport they are being plotted in, be that the full panel or a facet panel. A value of 0.5 indicates the center of the axis, and a value of 1 indicates the far edge of the axis.
This code and its documentation is based off code in the ggplot2 package, and thus is subject to the copy-left licenses of the original package.
geom_abs_text( mapping = NULL, data = NULL, stat = "identity", ..., parse = FALSE, inherit.aes = TRUE ) geom_abs_label( mapping = NULL, data = NULL, stat = "identity", ..., parse = FALSE, label.padding = unit(0.25, "lines"), label.r = unit(0.15, "lines"), label.size = 0.25, na.rm = FALSE, inherit.aes = TRUE ) annotate_abs_text(xpos, ypos, ...) annotate_abs_label(xpos, ypos, ...)
mapping, data, ..., stat, parse, inherit.aes |
See the documentation for |
... |
Other arguments passed on to |
label.padding, label.r, label.size |
See the documentation for |
xpos |
A numeric between 0 and 1, indicating the x position |
ypos |
A numeric between 0 and 1, indicating the y position |
This function has only been tested in a few scenarios, and only in ggplot2 v2.2.1
.
df <- data.frame( x = c(99, 0, 1), y = c(-100, 0, 100), label = c("A","B", "C") ) ggplot(df, aes(x=x,y=y,label=label, color=label)) + geom_point() + geom_text() + facet_wrap(~label, scales="free") + geom_abs_text(aes(xpos=0.5, ypos=0.75, label = paste0("relative: ", label))) + annotate_abs_label(xpos=0.25, ypos=0.25, label="wildcard!")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.