ggplot 图例中重叠的形状和字符
overlapping shape and character in ggplot legend
当我用相同颜色绘制点和文本时,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()
只需为您的 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()
当我用相同颜色绘制点和文本时,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()
只需为您的 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()