【问题标题】:Repositioning scatter plot labels in ggplot2在ggplot2中重新定位散点图标签
【发布时间】:2010-12-28 16:30:08
【问题描述】:

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

【问题讨论】:

    标签: r ggplot2


    【解决方案1】:

    我不确定这是否是您要查找的内容:

    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

    【讨论】:

    • 这正是我正在寻找的。谢谢!
    猜你喜欢
    • 2010-12-21
    • 1970-01-01
    • 2023-04-09
    • 1970-01-01
    • 1970-01-01
    • 2014-09-18
    • 2019-07-19
    • 1970-01-01
    • 2018-11-09
    相关资源
    最近更新 更多