Data Story

데이터 사이언스, 쉽게 설명하기

R

R Visualization - [plot]

_data 2022. 12. 6. 10:15

Plot

그림 1

x1 <- 1:5
y1 <- x1^2
z1 <- 5:1

plot(x1,y1,type='l')

 

 

파라미터

- type : 값 표현을 바꾼다.

e.g. type = 'p' | type = 'l'

- pch : 각 값을 해당 문자열로 표현한다.

e.g. pch = 'A' 

- lty : 선의 표현 방식을 바꾼다.

e.g. lty=2 | lty='blank' or 'solid'

 

그림 1에 수직선이나 사각형 등을 추가로 넣을 수 있다. (그림 2)

그림 2

x1 <- 1:5
y1 <- x1^2
z1 <- 5:1

plot(x1,y1,type='l')

##수직선 추가
abline(v=2)

 

 

- abline(v= y1) : 선을 그어준다.

parameter : [v,h...]

- rect(x1,y1, x2,y2) : 사각형을 그려준다.

parameter : [col, border, density, angle, lwd, lty...]

- text(x1, y1, "a" )

parameter : [pos, offset]  e.g., pos=1 / offset = 1

- legend('topright"/"bottomleft" ... , legend = " ")

parameter : [pch, col...]

- axis

parameter : [side, at, labels, line,width, tick, lty, lwd, col.axis...]

'R' 카테고리의 다른 글

R - [Normality]  (0) 2022.12.25
R - [Visualization. ggplot2]  (0) 2022.12.22
R - R Markdown command  (1) 2022.12.22
R Visualization - [boxplot]  (0) 2022.12.06
R Visualization - [dotchart]  (0) 2022.12.06