Notice
Recent Posts
Recent Comments
Link
«   2025/04   »
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30
Tags
more
Archives
Today
Total
관리 메뉴

자료 매번 검색하기 귀찮아서 만든 블로그

GGPLOT2 - 그림 양 옆 공백 없애기 본문

R

GGPLOT2 - 그림 양 옆 공백 없애기

쿠키아버님 2022. 9. 20. 15:25
library(ggplot2)

df<-data.frame(x=seq(0, 4),
               y=runif(5))

 

 

원하는 것은 GGPLOT에서 그림의 왼쪽과 오른쪽의 공백을 없애는 것이다.

ggplot(data=df)+
  geom_line(aes(x=x, y=y))

 

빨강색 영역을 없애고 싶다

 

 

scale_x_continuous를 사용하면 된다.

ggplot(data=df)+
  geom_line(aes(x=x, y=y))+
  scale_x_continuous(expand=c(0, 0))

그림의 양 옆 공백이 사라진 것을 확인할 수 있다.