在ggplot2中重新定位散点图标签

Bra*_*sen 4 r ggplot2

是否可以重新定位标签,使得在扇区(-x,y)中标签位于左侧,扇区(+ x,y)标签位于右侧?

rcs*_*rcs 8

我不确定这是不是你要找的东西:

library("ggplot2")
tmp <- data.frame(x=-5:5, y=rnorm(11), lab=LETTERS[1:11])
p <- ggplot(aes(x=x, y=y, label=lab), data=tmp) +
     geom_point() +
     geom_text(data=subset(tmp, x > 0), hjust=-0.5) +
     geom_text(data=subset(tmp, x <= 0), hjust=1.5)
print(p)
Run Code Online (Sandbox Code Playgroud)

geom_text标签http://img8.imageshack.us/img8/1056/geomtext.png