I am trying to figure how to use different coordinate systems for x and y coordinates in the text()
or grid.text()
functions (or any other similar functions in R).
In the example below I'd like to set the Y coordinates of the text()
function at 10% from the bottom of the screen instead of using the scale of the Y scale. I can do it with grid.text()
with y = 0.1 but I do not know how to set X positions of grid.text()
to the X scale of the plot. Basically, I'd like to mix the capabilities of text()
and grid.text()
functions.
I know that grid.text
has an option of passing units but I can't figure out how to use the units from the plot.
library(grid)
test= data.frame(
x = c(1,2,3),
y = c(12,10,3),
n = c(75,76,73)
)
par(mar = c(13,5,2,3))
plot(test$y ~ test$x,type="b")
text(x=test$x, y=-2, label=test$n, xpd=T)