The R Project SVN R

Rev

Rev 59510 | Rev 61156 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 59510 Rev 61153
Line 131... Line 131...
131
x <- 0:12
131
x <- 0:12
132
y <- sin(pi/5 * x)
132
y <- sin(pi/5 * x)
133
op <- par(mfrow = c(3,3), mar = .1+ c(2,2,3,1))
133
op <- par(mfrow = c(3,3), mar = .1+ c(2,2,3,1))
134
for (tp in c("p","l","b",  "c","o","h",  "s","S","n")) {
134
for (tp in c("p","l","b",  "c","o","h",  "s","S","n")) {
135
   plot(y ~ x, type = tp,
135
   plot(y ~ x, type = tp,
136
        main = paste("plot(*, type = \"",tp,"\")",sep=""))
136
        main = paste("plot(*, type = \"",tp,"\")", sep = ""))
137
   if(tp == "S") {
137
   if(tp == "S") {
138
      lines(x,y, type = "s", col = "red", lty = 2)
138
      lines(x,y, type = "s", col = "red", lty = 2)
139
      mtext("lines(*, type = \"s\", ...)", col = "red", cex=.8)
139
      mtext("lines(*, type = \"s\", ...)", col = "red", cex = .8)
140
   }
140
   }
141
}
141
}
142
par(op)
142
par(op)
143
 
143
 
144
##--- Log-Log Plot  with  custom axes
144
##--- Log-Log Plot  with  custom axes
145
lx <- seq(1,5, length=41)
145
lx <- seq(1,5, length = 41)
146
yl <- expression(e^{-frac(1,2) * {log[10](x)}^2})
146
yl <- expression(e^{-frac(1,2) * {log[10](x)}^2})
147
y <- exp(-.5*lx^2)
147
y <- exp(-.5*lx^2)
148
op <- par(mfrow=c(2,1), mar=par("mar")+c(0,1,0,0))
148
op <- par(mfrow = c(2,1), mar = par("mar")+c(0,1,0,0))
149
plot(10^lx, y, log="xy", type="l", col="purple",
149
plot(10^lx, y, log = "xy", type = "l", col = "purple",
150
     main="Log-Log plot", ylab=yl, xlab="x")
150
     main = "Log-Log plot", ylab = yl, xlab = "x")
151
plot(10^lx, y, log="xy", type="o", pch='.', col="forestgreen",
151
plot(10^lx, y, log = "xy", type = "o", pch = '.', col = "forestgreen",
152
     main="Log-Log plot with custom axes", ylab=yl, xlab="x",
152
     main = "Log-Log plot with custom axes", ylab = yl, xlab = "x",
153
     axes = FALSE, frame.plot = TRUE)
153
     axes = FALSE, frame.plot = TRUE)
154
my.at <- 10^(1:5)
154
my.at <- 10^(1:5)
155
axis(1, at = my.at, labels = formatC(my.at, format="fg"))
155
axis(1, at = my.at, labels = formatC(my.at, format = "fg"))
156
at.y <- 10^(-5:-1)
156
at.y <- 10^(-5:-1)
157
axis(2, at = at.y, labels = formatC(at.y, format="fg"), col.axis="red")
157
axis(2, at = at.y, labels = formatC(at.y, format = "fg"), col.axis = "red")
158
par(op)
158
par(op)
159
}
159
}
160
\keyword{hplot}
160
\keyword{hplot}