我正在尝试使用geom_text()
在散点图上显示一些统计信息,但是当我反转x轴时,文本会消失。
x = rnorm(20, mean = 10)
y = rnorm(20, mean =30)
R2 = cor(x, y)^2
R2 = signif(R2, 2)
df = data.frame(x, y)
# It works on a normal axis.
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))
# But the text disappears when I reverse the x-axis:
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")
感谢您的任何建议。
答案 0 :(得分:1)
以下内容也只会写一次文本,并会显示您提供的第一个示例中的值:
func setUp() {
super.setUp();
XCUIApplication().launch
}