데카르트방식 : plot(x,y) 수식기반 : plot(y~x) plot() plot(y축 data, option) plot( c(1,2,3,4,5))
target <- c(100,130,120,160,150) plot( target, type = ‘o’, col = ‘red’, ylim = c(0,200), axes = F, ann = F ) axis( 1, at = 1:5, lab = c(‘월’,‘화’,‘수’,‘목’,‘금’) ) axis( 2, ylim = c(0,200) ) title( main = “과일”, col.main = “red”, font.main = 4 ) title( xlab = “요일”, col.lab = “black” ) title( ylab = “가격”, col.lab = “blue” )
library(ggplot2)
## Warning: package 'ggplot2' was built under R version 3.5.1
set.seed(1228)
var.rand <- data.frame(
obs <- 1:20,
val <- sample(
1:10,
size = 20,
replace = T
)
)
var.rand
ggplot(
data = var.rand,
aes(x = obs,
y = val
)
)+geom_point()
ggplot(
data = var.rand)+
geom_point(
aes(x = obs,
y = val
),
color = "blue", # 포인트 색깔& 사이즈 추가
size = 5)
set.seed(3000)
var.rand <- data.frame(
obs <- 1:20,
val <- sample(
1:10,
size = 20,
replace = T
)
)
var.rand
ggplot(
data = var.rand)+
geom_line(
aes(x = obs,
y = val ))
ggplot(
data = var.rand)+
geom_line(
aes(x = obs,
y = val ),
color = "red", # 선 색깔& 사이즈 추가
size = 2)
set.seed(123)
dfRand <- data.frame(aa = 1:10,
bb = sample(1:10, 10)
)
head(dfRand)
ggplot(data = dfRand,
aes(x = aa,
y = bb
)
)+geom_point(size = 5)+
geom_line(size = 1.5)+
geom_point(size = 3, color = "#FFFFFF")
dfDemo1 <- data.frame(aa=1:10, bb=10:1)
dfDemo2 <- data.frame(cc=1:10, dd=1:10)
ggplot(
data = dfDemo2,
aes(x=cc, y=dd)
)+ geom_col(data=dfDemo1,
aes(x=aa,y=bb))+
geom_point(size=5)+
geom_line(size=1.5)+
geom_point(size=3,
color="#FFFFFF")
target <- c(100,130,120,160,150)
plot(
target,
type = 'o',
col = 'red',
ylim = c(0,200),
axes = F,
ann = F
)
axis(
1,
at = 1:5,
lab = c('월','화','수','목','금')
)
axis(
2,
ylim = c(0,200)
)
title(
main = "과일",
col.main = "red",
font.main = 4
)
title(
xlab = "요일",
col.lab = "black"
)
title(
ylab = "가격",
col.lab = "blue"
)