2012-05-22 2 views
8

하늘에 천체를 그려보기 위해 노력 중입니다 (기본적으로 위도/경도 좌표와 동일). coord_map 함수의 "aitoff" 투영법을 사용하여 모든 포인트를 성공적으로 플로팅했지만,이 경우 그리드가 잘못 표시됩니다. 즉, 정확한 투영과 함께 0이 아닌 위도에 대해 잔여 수평선이 계속 표시됩니다.ggplot2를 사용하여 그리드가 잘못 표시되었습니다.

enter image description here

어떻게이 라인을 제거 할 수 있습니다?

library(ggplot2) 
library(mapproj) 
sky2 = data.frame(RA=0, Dec=0) 
skyplot2 <- qplot(RA,Dec,data=sky2,xlim=c(0,360),ylim=c(-89.999,89.999), 
xlab="R.A.(°)", ylab="Decl. (°)",main="Source repartition on the sky") 
skyplot2 + coord_map(projection="aitoff",orientation=c(89.999,180,0)) + 
scale_y_continuous(breaks=(-2:2)*30,limits=c(-89.999,89.999)) + 
scale_x_continuous(breaks=(0:8)*45,limits=c(0,360), 
        labels=c("","","","","","","","","")) 

답변

4

확실히이 그래서 당신이 버그를 제출하시기 바랍니다 수 ggplot2에서 버그가 여기에

는 동작을 재현 코드를 무엇입니까? https://github.com/hadley/ggplot2/issues?state=openFiled as a bug.

여기가 빠르고 더러운 해킹입니다. 이것은 에이 토프 도법에서만 작동 할 수 있다는

f <- function(x, y, ...) { 
    if (any(is.na(x))) { 
    id <- rle(!is.na(x))$length 
    id <- rep(seq_along(id), id) 
    df <- data.frame(x, y, id) 
    df <- df[order(df$id, df$x), ] 
    } else if (any(is.na(y))) { 
    id <- rle(!is.na(y))$length 
    id <- rep(seq_along(id), id) 
    df <- data.frame(x, y, id) 
    } 
    polylineGrob(df$x, df$y, id = df$id, gp = gpar(col = "white")) 
} 

skyplot2 <- qplot(RA,Dec,data=sky2,xlim=c(0,360),ylim=c(-89.999,89.999), 
        xlab="R.A.(°)", ylab="Decl. (°)",main="Source repartition on the sky") 
skyplot2 + coord_map(projection="aitoff",orientation=c(89.999,180,0)) + 
    scale_y_continuous(breaks=(-2:2)*30,limits=c(-89.999,89.999)) + 
    scale_x_continuous(breaks=(0:8)*45,limits=c(0,360), 
        labels=c("","","","","","","","","")) + 
        opts(panel.grid.major = f) 

enter image description here

참고.

2

당신은 단지 추가해야합니다 :

+ opts(axis.ticks = theme_blank()) 
+0

흠. 그것은 그림의 하단에있는 진드기를 제거하지만 OP가 제거하고자하는 여분의 (직선) 수평선은 제거하지 않습니다. –

+0

오 wops. 질문을 면밀히 읽지 않았습니다. –

관련 문제