티스토리 뷰

김승욱님 강의를 듣고 작성하였습니다.

 

[R을 R려줘] R 시각화 기초 - 인프런

R 문법 기초에 이어서 진행되는 시각화 강좌 입니다. R의 강력한 시각화 패키지인 ggplot2를 집중적으로 배웁니다. 입문 데이터 분석 프로그래밍 언어 R 온라인 강의

www.inflearn.com

 

기호 변경

데이터 준비

> bar_df = data.frame( obs = 1:10,
+                      var = rep(c('A','B','C'), length.out=10),
+                      value = sample(1:100, size=10),
+                      stringsAsFactors = FALSE)
> head(bar_df)
  obs var value
1   1   A    67
2   2   B    12
3   3   C    43
4   4   A    11
5   5   B    75
6   6   C    63


그래프 1

ggplot(data = bar_df, aes(x=obs,
                          y=value,
                          color=value))+
  geom_point(size=10)

color가 아니라 colour로 써도 된다.

 

그래프 2

ggplot(data = bar_df, aes(x=obs,
                          y=value,
                          color=value))+
  geom_point(size=10,
             shape = 1)

 

그래프 3

ggplot(data = bar_df, aes(x=obs,
                          y=value,
                          color=value))+
  geom_point(size=10,
             shape = 2)

 

그래프4

ggplot(data = bar_df, aes(x=obs,
                          y=value,
                          color=value,
                          shape=var))+
  geom_point(size=10)+
  scale_shape_manual(values = c('A'=7,
                                'B'=8,
                                'C'=9))

shape=var 하면 알아서 A,B,C 별로 자동으로 모양이 지정된다.

하지만 자기가 직접 모양을 지정하고 싶다면 scale_shape_manual을 사용하면 된다.

 

각종 기호

 

그래프5

ggplot(data = bar_df, 
       aes(x=obs,
           y=value,
           color=value))+
  geom_point(size = 10,
             shape = '나')

'나' 라고 나와야 하는데 글자가 깨진다.. 이유는 나중에 찾아봐야징

'beginner > R 시각화 기초' 카테고리의 다른 글

ggplot 덧그리기  (0) 2019.08.12
ggplot 텍스트 설정  (0) 2019.08.08
ggplot 축 설정  (0) 2019.08.07
ggplot 색상 설정-3  (0) 2019.08.06
ggplot 색상설정-2  (0) 2019.08.01
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/05   »
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 31
글 보관함