fpr*_*prd 3 r line ggplot2 axis-labels
这是数据:
myd <- data.frame (X1 = rep (c("A0001", "B0002", "C0003", "D0004"), each = 2),
X2 = rep (c(1, 5.3, 8.2, 12.5), each = 2), X3 = rep (c("A", "B"), 4),
Y = rnorm (8, 5, 2))
Run Code Online (Sandbox Code Playgroud)
这是我可以绘制的情节:
require(ggplot2)
ggplot(myd, aes(x = X2, y = Y, group = X3)) +
geom_point (aes(col = X3, pch = X3)) + geom_line (aes(col = X3))
Run Code Online (Sandbox Code Playgroud)
除了X2值之外,我想将X1文本转换为x轴上的相应位置.干草图:

我该怎么做 ?编辑:
注意:目的是在X轴上同时显示连续比例和文本:
创建两个新图层:
geom_rug 对于轴上的线geom_text 对于标签 - 但首先创建所需标签的摘要代码:
ruglabels <- unique(myd[, 1:2])
require(ggplot2)
ggplot(myd, aes(x=X2, y=Y)) +
geom_point (aes(col = X3, pch = X3, col=X3)) +
geom_line (aes(col = X3, col=X3)) +
geom_rug(sides="b") +
geom_text(data=ruglabels, aes(x=X2, label=X1, y=2))
Run Code Online (Sandbox Code Playgroud)
