I am trying to display some statistics about the spread using geom_text(), but the text disappears when I cancel the x axis.
x = rnorm(20, mean = 10)
y = rnorm(20, mean =30)
R2 = cor(x, y)^2
R2 = signif(R2, 2)
df = data.frame(x, y)
library(ggplot2)
ggplot(df, aes(x = x, y = y)) + geom_point(shape = 1) +
geom_text(label=paste("italic(R^2)==",R2), x = 10, y = 30, parse = T) +
scale_x_continuous(limits = c(6, 14))
ggplot(df, aes(x = x, y = y)) + geom_point(shape = 1) +
geom_text(label=paste("italic(R^2)==",R2), x = 10, y = 30, parse = T) +
scale_x_continuous(limits = c(14, 6), trans="reverse")
Thanks for any suggestions.
source
share