【问题标题】:overlapping shape and character in ggplot legendggplot图例中重叠的形状和字符
【发布时间】:2015-04-22 14:34:04
【问题描述】:

当我用相同颜色绘制点和文本时,a 和图例中的形状重叠。

我可以告诉ggplot不要在图例中绘制a吗?怎么样?

M <- data.frame(t=letters[1:16],
            xx=runif(16),
            yy=runif(16),
            g=rep(c("A","B","C","D"),4))
str(M)

ggplot(M,aes(x=xx,y=yy,label=t,colour=g)) + 
       geom_point(shape=3) + 
       geom_text(vjust=0,hjust=0) + 
       scale_colour_discrete()

【问题讨论】:

    标签: r ggplot2


    【解决方案1】:

    只需为您的geom_text 添加show_guide = F

    ggplot(M,aes(x=xx,y=yy,label=t,colour=g)) + 
      geom_point(shape=3) + 
      geom_text(vjust=0,hjust=0, show_guide = F) +
      scale_colour_discrete()
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-03-03
      • 1970-01-01
      • 2013-02-06
      • 1970-01-01
      相关资源
      最近更新 更多