본문 바로가기
공부/R Programming

R 기초; 그래픽 - 그래프 패러미터 설정

by 혼밥맨 2021. 1. 23.
반응형

R 기초; 그래픽 - 그래프 패러미터 설정

 

plot(faithful)

 

plot(faithful, main="Old Faithful Geyser", sub="Yellowstone National Park", xlab="Eruptio time (minutes)", ylab="Waiting time (minutes)")

 

?par

 

plot(faithful, las=0)

plot(faithful, las=1)

plot(faithful, las=2)

plot(faithful, las=3)

 

plot(faithful, bty="o")

plot(faithful, bty="n")

plot(faithful, bty="l")

plot(faithful, bty="]")

 

# 심볼과 선

plot(faithful, pch=3)

plot(faithful, pch=8)

plot(faithful, pch=19, col="green3")

plot(faithful, pch=21)

plot(faithful, pch=21, col="dimgray", bg="red")

 

str(LakeHuron)

plot(LakeHuron)

plot(LakeHuron, lty="solid")

plot(LakeHuron, lty=1)

plot(LakeHuron, lty="dashed")

plot(LakeHuron, lty="dotted")

plot(LakeHuron, lty="dotdash")

plot(LakeHuron, lty="longdash")

plot(LakeHuron, lty="twodash")

plot(LakeHuron, lty=6)

plot(LakeHuron, lty=6, col="red")

 

# 그래프 유형

 

str(pressure)

plot(pressure)

plot(pressure, type="p")

plot(pressure, type="l")

?plot

 

plot(pressure, type="b")

plot(pressure, type="o")

plot(pressure, type="h")

plot(pressure, type="s")

 

x <- 1:10

y1 <- exp(1:10)

y2 <- exp(10:1)

plot(x, y1, xlab="x", ylab="y", type="n")

lines(x, y1, type="o", pch=21, col="red")

lines(x, y2, type="o", pch=22, col="blue")

 

plot(faithful)

plot(faithful, type="n")

grid()

points(faithful, pch=19, col="blue")

 

 

# 색상

colors()

palette()

palette(rainbow(6))

palette()

palette("default")

palette()

 

n <- 12

pie(rep(1, n), col=1:n)

rainbow()

heat.colors()

terrain.colors()

 

# 크기

pie(rep(1, n), col=rainbow(n, alpha=seq(0, 1, length=n)))

 

library(RColorBrewer)

?RColorBrewer

 

display.brewer.all()

display.brewer.pal(3, "Dark2")

display.brewer.pal(9, "Blues")

 

n <- 9

pie(rep(1, n), col=brewer.pal(n, "Blues"))

pie(rep(1, n), col=brewer.pal(n, "Greens"))

pie(rep(1, n), col=brewer.pal(n, "BuGn"))

pie(rep(1, n), col=brewer.pal(n, "GnBu"))

 

 

plot(faithful, pch=19, col="tomato",

      main="Old Faithful Geyser",

      sub = "Yellowstone National Park",

      xlab = "Eruption time (minutes)",

      ylab = "Waiting time (minutes)",

      col.main = "navy", col.sub="purple",

      col.lab="royalblue", col.axis="brown")

 

# 크기

x <- seq(0.5, 1.5, 0.25)

y <- rep(1, length(x))

 

plot(x, y, pch=19, cex=x, main="Effects of cex on symbol and text size")

 

text(x, y+0.2, labels=x, cex=x)

 

plot(x, y, pch=19, cex=x, main="Effects of cex on symbol and text size", cex.main=1.5, cex.lab=1.0, cex.axis=0.75)

 

plot(LakeHuron, lwd=1)

plot(LakeHuron, lwd=2)

 

 

# 글꼴과 글씨체

windowsFonts()

 

plot(faithful, pch=19, col="tomato",

      main="Old Faithful Geyser",

      sub = "Yellowstone National Park",

      xlab = "Eruption time (minutes)",

      ylab = "Waiting time (minutes)",

      col.main = "navy", col.sub="purple",

      col.lab="royalblue", col.axis="brown")

 

windowsFonts(

   A = windowsFonts("Arial Black"),

   B = windowsFonts("Book Antiqua"),

   C = windowsFonts("Calisto MT")

)

 

 

반응형

댓글