2010-05-10 3 views
8

를 사용하는 경우, 우리 한 다음의 간단한 줄거리 : alt text http://had.co.nz/ggplot2/graphics/1dd785939e74fc3e6090dce6bc7f01c6.png여백 조정 ggplot의 geom_tile() ggplot2의 <a href="http://had.co.nz/ggplot2/geom_tile.html" rel="nofollow noreferrer">geom_tile()</a> 기능에 대한 설명서에서

# Generate data 
pp <- function (n,r=4) { 
    x <- seq(-r*pi, r*pi, len=n) 
    df <- expand.grid(x=x, y=x) 
    df$r <- sqrt(df$x^2 + df$y^2) 
    df$z <- cos(df$r^2)*exp(-df$r/6) 
    df 
} 
p <- ggplot(pp(20), aes(x=x,y=y)) 

p + geom_tile() 

어떻게 타일 테두리 여백을 제거 할 수 있습니까? 나는 아무 쓸모없는 약간의 힌트를 위해 이것을 script on polishing plots 통해 파헤 쳤다. opts (panel.background = theme_blank())를 사용하여 배경 패널을 제거하는 방법을 찾았지만 여백 크기를 변경하는 방법은 찾지 못했습니다.

답변

20

이 시도 :

p + geom_tile() + 
    scale_x_continuous(expand=c(0,0)) + 
    scale_y_continuous(expand=c(0,0)) 
+1

감사합니다! 빠른 추가 : 연속 변수 대신 인수가있는 경우 scale_x_continuous를 scale_x_discrete로 바꾸면됩니다. –