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:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
|
# Setting up an Outer Margin Area and a Margin Area befor Drawing a Plot
par(mfrow = c(1, 1)) # 1 row and 1 col
# sides: 1 - Bottom, 2 - Left, 3 - Top, 4 - Right
par(mar = c(5, 4, 3, 2)) # spaces for all sides.
par(oma = c(2, 3, 4, 5)) # spaces for all sides.
# Plot
x=-40:40; x=x/10;
y=sin(x)
plot(x, y, xlab="X-Axis", ylab="Y-Axis", cex=0.5, xlim=c(-pi, pi), main="Sine Graph") # type="n" hides the points
lines(x, y, col="red", lty=21)
abline(v=0, col="green", lty=21)
abline(h=0, col="blue", lty=21)
text(0, 0, "CENTER", col="Gray", cex=3)
# Margin Area
mtext("Margin Area - Side 1", side=1, line=2, adj=0.0, cex=2, col="red")
mtext("side=1, line=0, adj=1.0", side=1, line=0, adj=1.0, cex=1, col="red")
mtext("side=1, line=1, adj=1.0", side=1, line=1, adj=1.0, cex=1, col="red")
mtext("side=1, line=2, adj=1.0", side=1, line=2, adj=1.0, cex=1, col="red")
mtext("side=1, line=3, adj=1.0", side=1, line=3, adj=1.0, cex=1, col="red")
mtext("side=1, line=4, adj=1.0", side=1, line=4, adj=1.0, cex=1, col="red")
mtext("side=1, line=5, adj=1.0", side=1, line=5, adj=1.0, cex=1, col="red")
mtext("side=1, line=6, adj=1.0", side=1, line=6, adj=1.0, cex=1, col="red")
mtext("Margin Area - Side 2", side=2, line=2, adj=0.0, cex=2, col="red")
mtext("side=2, line=0, adj=1.0", side=2, line=0, adj=1.0, cex=1, col="red")
mtext("side=2, line=1, adj=1.0", side=2, line=1, adj=1.0, cex=1, col="red")
mtext("side=2, line=2, adj=1.0", side=2, line=2, adj=1.0, cex=1, col="red")
mtext("side=2, line=3, adj=1.0", side=2, line=3, adj=1.0, cex=1, col="red")
mtext("side=2, line=4, adj=1.0", side=2, line=4, adj=1.0, cex=1, col="red")
mtext("side=2, line=5, adj=1.0", side=2, line=5, adj=1.0, cex=1, col="red")
mtext("side=2, line=6, adj=1.0", side=2, line=6, adj=1.0, cex=1, col="red")
mtext("Margin Area - Side 3", side=3, line=2, adj=0.0, cex=2, col="red")
mtext("side=3, line=0, adj=1.0", side=3, line=0, adj=1.0, cex=1, col="red")
mtext("side=3, line=1, adj=1.0", side=3, line=1, adj=1.0, cex=1, col="red")
mtext("side=3, line=2, adj=1.0", side=3, line=2, adj=1.0, cex=1, col="red")
mtext("side=3, line=3, adj=1.0", side=3, line=3, adj=1.0, cex=1, col="red")
mtext("side=3, line=4, adj=1.0", side=3, line=4, adj=1.0, cex=1, col="red")
mtext("side=3, line=5, adj=1.0", side=3, line=5, adj=1.0, cex=1, col="red")
mtext("side=3, line=6, adj=1.0", side=3, line=6, adj=1.0, cex=1, col="red")
mtext("Margin Area - Side 4", side=4, line=2, adj=0.0, cex=2, col="red")
mtext("side=4, line=0, adj=1.0", side=4, line=0, adj=1.0, cex=1, col="red")
mtext("side=4, line=1, adj=1.0", side=4, line=1, adj=1.0, cex=1, col="red")
mtext("side=4, line=2, adj=1.0", side=4, line=2, adj=1.0, cex=1, col="red")
mtext("side=4, line=3, adj=1.0", side=4, line=3, adj=1.0, cex=1, col="red")
mtext("side=4, line=4, adj=1.0", side=4, line=4, adj=1.0, cex=1, col="red")
mtext("side=4, line=5, adj=1.0", side=4, line=5, adj=1.0, cex=1, col="red")
mtext("side=4, line=6, adj=1.0", side=4, line=6, adj=1.0, cex=1, col="red")
# Boxes
box("plot" , col="red" , lty=12) # "plot", "figure", "inner" and "outer"
box("figure", col="blue" , lty=12) # "plot", "figure", "inner" and "outer"
box("inner" , col="green" , lty=12) # "plot", "figure", "inner" and "outer"
box("outer" , col="purple", lty=12) # "plot", "figure", "inner" and "outer"
# Outer Margin
mtext("Outer Margin Area - Side 1", side=1, line=1, cex=2, col="blue", outer=TRUE)
mtext("side=1, line=0, adj=0.0", side=1, line=0, adj=0.0, cex=1, col="blue", outer=TRUE)
mtext("side=1, line=1, adj=0.0", side=1, line=1, adj=0.0, cex=1, col="blue", outer=TRUE)
|