Layer :: position (adjustments)

Published by onesixx on

Layer내 element의 위치 미세 조정

점 (geom_point)

  • position_nudge        고정 간격 
  • position_jitter            겹치지 않게, 랜덤 노이즈 추가
  • position_jitterdodge  그룹내 점을 피해, 램덤 노이즈 추가

막대 (geom_bar) 

이산형 (bar plot, histogram)의 객체위치조정

  • position_identity   default, 특별한 배치가 필요없이 있는 그대로 배치
  • position_stack        겹쳐 쌓기 (default)
  • position_fill            항상 1을 기준으로 겹쳐 쌓기
  • position_dodge    겹치는막대 나란히 배치

이산형값의 stacking효과를 위한 객체위치 튜닝에 주로 사용됨.

diamonds %>% ggplot(aes(x=cut, fill=cut))     +\tgeom_bar()
diamonds %>% ggplot(aes(x=cut, fill=clarity)) +\tgeom_bar()
This image has an empty alt attribute; its file name is 96e1f54678854e4ea33feac6f7f16a2d.png
This image has an empty alt attribute; its file name is 5883df2f676148023274d5410c526d76.png
diamonds %>% ggplot(aes(x=cut, fill=clarity)) +\tgeom_bar(position="identity")
diamonds %>% ggplot(aes(x=cut, fill=clarity)) +\tgeom_bar(position="stack")
diamonds %>% ggplot(aes(x=cut, fill=clarity)) +\tgeom_bar(position="dodge")
diamonds %>% ggplot(aes(x=cut, fill=clarity)) +\tgeom_bar(position="fill")

많은 점들이  overlap되었을때  overplotting. 문제가 있다고 하고,  geom_point(position = "jitter"): geom_jitter().를 이용하여 해결한다. 

ggplot(mpg) + 
  geom_point(aes(x = displ, y = hwy), position = "jitter")
Categories: ggplot2

onesixx

Blog Owner

Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x