x <- c(1:10)
y <- x^2 - x + 10
plot(x, y)

# type
plot(x, y, type = "p" ) # 점 출력 - default
plot(x, y, type = "n" ) # 아무것도 출력x
imageimage
plot(x, y, type = "S" ) # 계단식S : 해당값에서 올라갔다가 다음값으로 감
plot(x, y, type = "s" ) # 계단식s : 해당값에서 다음값으로 갔다가 올라감
imageimage
plot(x, y, type = "h" ) # bar와 비슷한데 선이 올라옴

image


# col
plot(x, y, type = "h", col = "blue" )
image

# pch - point의 모양바꾸기
plot(x, y, type = "p", col = "blue", pch = 1) # 동그라미 - default
plot(x, y, type = "p", col = "blue", pch = 2) # 세모
plot(x, y, type = "p", col = "blue", pch = 3) # +
plot(x, y, type = "p", col = "blue", pch = 4) # X
plot(x, y, type = "p", col = "blue", pch = 5) # 다이아몬드

# *** par(mfrow=c(nrow,ncol) + for()문을 이용하여 여러개 plot 동시에 그리기 ***
par(mfrow = c(2,4))
for(i in 1:8){
   plot(x, y, type ="p", col="blue", pch = i)
}
image


par(mfrow = c(2,4))
for(i in 9:16){
   plot(x, y, type ="p", col="blue", pch = i)
}

image


types = c("p", "l", "o", "b", "c", "s", "S", "h") # "o" = 점+선 overlap
par(mfrow = c(2,4))
for(i in 1:8){
   plot(x, y, type = types[i], col="blue")
}

image

+ Recent posts