开发者

Repositioning scatter plot labels in ggplot2

开发者 https://www.devze.com 2022-12-14 08:15 出处:网络
Is it possible to reposition the labels such t开发者_如何转开发hat in sector (-x,y) the label is on the left and sector (+x,y) the label is on the right?I\'m not definitely sure if this is what you we

Is it possible to reposition the labels such t开发者_如何转开发hat in sector (-x,y) the label is on the left and sector (+x,y) the label is on the right?


I'm not definitely sure if this is what you were looking for:

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)

geom_text labeling http://img8.imageshack.us/img8/1056/geomtext.png

0

精彩评论

暂无评论...
验证码 换一张
取 消