2012-07-13 3 views
4
test <- data.frame(
    y=seq(18,41,1), 
    x=24:1 
) 

ggplot(test, aes(y=y, x=x)) + geom_bar(stat="identity", aes(width=1)) + 
    opts(axis.text.x = theme_blank(), axis.ticks.x = theme_blank()) + 
    scale_x_continuous(breaks=NULL) + 
    coord_cartesian(ylim = c(17, 42)) 

enter image description hereggplot geom_bar - '회전하고 뒤집기'하시겠습니까?

지금까지 회전과 반전에 관한 한, 나는 상단가이 음모의 y 축이며, 오른쪽 아래로 될 수있는 x 축이 무엇 무엇을하고 싶습니다 측면. 그래서 바는 가장 길고/가장 높고 가장 아래쪽이 가장 짧고 음모의 오른쪽에서 바깥으로 나오고 있습니다. 시계 방향으로 90도 회전 한 다음 그것을 달성 할 수있는 수직선 위로 뒤집 으면.

coord_flip() 및 scale_y_reverse()가 올바른 경로로 내려갑니다.

편집 :

나는이 꽤 가까운 것 같다 단지 그래프 상단에 그 y 축를 얻을 필요가있다.

ggplot(test, aes(y=y, x=x)) + geom_bar(stat="identity", aes(width=1)) + 
    opts(axis.text.y = theme_blank(), axis.ticks.y = theme_blank()) + 
    scale_x_continuous(breaks=NULL) + scale_y_reverse() + coord_flip() + scale_x_reverse() 

답변

9

정확히 설명하지는 않지만 충분히 근접해 있습니까?

ggplot(test, aes(y=y, x=x)) + geom_bar(stat="identity", aes(width=1)) + 
    coord_flip() + 
    xlim(24, 1) + 
    ylim(42, 0) 

비결은 역순으로 xlimylim 인수를하는 것입니다. 귀하의 축 위치는

enter image description here

+0

@nzcoops 전혀이 도움이 되었습니까 ... 여전히 하단 왼쪽입니까? – Andrie