2016-08-28 4 views
0

포리스트 음모를 꾸미기 위해 coord_flip()을 사용하고 있습니다.ggplot2에서 범주 적 눈금 간격을 변경하는 방법은 무엇입니까?

df <- data.frame(f1=factor(rbinom(100, 1, 0.45), label=c("m","w")),   
    f2=factor(rbinom(100, 1, 0.45), label=c("young","old")), 
      boxthis1=rnorm(100), boxthis2=rnorm(100), boxthis3=rnorm(100)) 

ggplot(aes(ymin = boxthis1, y=boxthis2,ymax=boxthis3, x = f1), data = df) + 
    geom_pointrange(size=0.5) +coord_flip() 

VERTICAL 축에서 두 개의 플롯/축 레이블 사이의 거리가 더 멀어 지도록 만들려면 어떻게해야합니까?

+0

? 당신은 단지 하나의 줄거리와 하나의 축을 가지고 있습니다 ... 나는 틀릴 수도 있지만 두 줄이 서로 가깝도록 줄거리를 조정할 방법을 찾고 있다고 생각합니까? 그렇다면 당신의 질문은 음모의 크기를 조절하는 것에 관한 것이어야합니다 .... –

답변

0

scale_x_discrete(expand = ...)을 사용하는 것이 좋습니다. 어떤 두 플롯 사이

ggplot(aes(ymin = boxthis1, y=boxthis2,ymax=boxthis3, x = f1), data = df) + 
    geom_pointrange(size=0.5) +coord_flip() + scale_x_discrete(expand=c(0.2, 0.2)) 

enter image description hereenter image description here

관련 문제