2012-01-04 2 views
9

나는 여분의 데이터가있는 막대 그림을 만들려고합니다. 각 데이터 요소와 연관된 것은 높이가 왜 그 것인지를 나타내는 요소의 값입니다. 지금까지 나는 내 결과를 합리적으로 행복 해요 : example outputgeom_point {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) 

이는 다음과 같습니다 플롯을 생성합니다. 그 서클을 제거하고 싶지만 전설은 지키십시오. ggplot2가이 일을하게합니까?

+0

. 그렇게하면 문제가 해결되지만 다른 문제가 발생합니다. 막대 끝의 점은 xaxis 범주 내에서 반 무작위로 섞입니다. –

답변

18

이 시도 : 나는 모든 플롯에 적용 할 것을 채우기 = 분석의 원인이되는 ggplot 통화에서 AES에서 채우기 = 분석을 제거하는 시도

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)) + 
... 

enter image description here

+0

와우! 감사. 이 얼마나 쉬운 수정. –

관련 문제