如何使用geom_point {ggplot2}获取条形图末端的点而不在图例中获取圆圈?

Arl*_*Cox 9 r ggplot2

我正在尝试制作一个有额外数据的条形图.与每个数据点相关联的是来自一个因子的值,该因子指示高度为何的高度.到目前为止,我对我的结果感到满意:

library(ggplot2)

tab <- read.table("http://www.cs.colorado.edu/~coxaj/table2.csv",
            header=T, sep=",", strip.white=T)
tab <- with(tab, tab[order(Analysis, -as.numeric(Analysis)), ])

bar_width <- 0.5
space_width <- 0.8

p <- ggplot(tab, aes(x=Filter,y=Depth,fill=Analysis)) +
  geom_bar(position=position_dodge(width=space_width), width=bar_width) +
  geom_point(position=position_dodge(width=space_width), aes(shape=Termination)) +
  scale_shape_manual(values=c(1,4,5,6)) +
  geom_hline(aes(yintercept=16, linetype=2)) +
  scale_x_discrete(name='') +
  scale_y_continuous(name='Search Depth') +
  scale_fill_manual(values=c("#E66101", "#FDB863", "#B2ABD2", "#5E3C99")) +
  theme_bw()

ggsave(filename='table2.pdf', height=3, width=8)
Run Code Online (Sandbox Code Playgroud)

这会产生如下图: 示例输出

问题是它将这些毫无意义的圆圈放在分析的图例中.我想删除那个圈子,但保留传说.ggplot2让我这样做吗?

koh*_*ske 18

试试这个:

p <- ggplot(tab, aes(x=Filter,y=Depth)) +
  geom_bar(aes(fill = Analysis), 
           position=position_dodge(width=space_width), width=bar_width) +
  geom_point(position=position_dodge(width=space_width), 
             mapping = aes(group = Analysis, shape=Termination)) +
...
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述