The R Project SVN R

Rev

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

Rev 61156 Rev 61168
Line 119... Line 119...
119
  \code{\link{plot}}, \code{\link{plot.window}}, \code{\link{xy.coords}}.
119
  \code{\link{plot}}, \code{\link{plot.window}}, \code{\link{xy.coords}}.
120
}
120
}
121
\examples{
121
\examples{
122
Speed <- cars$speed
122
Speed <- cars$speed
123
Distance <- cars$dist
123
Distance <- cars$dist
124
plot(Speed, Distance, panel.first = grid(8,8),
124
plot(Speed, Distance, panel.first = grid(8, 8),
125
     pch = 0, cex = 1.2, col = "blue")
125
     pch = 0, cex = 1.2, col = "blue")
126
plot(Speed, Distance,
126
plot(Speed, Distance,
127
     panel.first = lines(stats::lowess(Speed, Distance), lty = "dashed"),
127
     panel.first = lines(stats::lowess(Speed, Distance), lty = "dashed"),
128
     pch = 0, cex = 1.2, col = "blue")
128
     pch = 0, cex = 1.2, col = "blue")
129
 
129
 
Line 132... Line 132...
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, main = paste0("plot(*, type = \"", tp, "\")"))
135
   plot(y ~ x, type = tp, main = paste0("plot(*, type = \"", tp, "\")"))
136
   if(tp == "S") {
136
   if(tp == "S") {
137
      lines(x,y, type = "s", col = "red", lty = 2)
137
      lines(x, y, type = "s", col = "red", lty = 2)
138
      mtext("lines(*, type = \"s\", ...)", col = "red", cex = 0.8)
138
      mtext("lines(*, type = \"s\", ...)", col = "red", cex = 0.8)
139
   }
139
   }
140
}
140
}
141
par(op)
141
par(op)
142
 
142
 
143
##--- Log-Log Plot  with  custom axes
143
##--- Log-Log Plot  with  custom axes
144
lx <- seq(1,5, length = 41)
144
lx <- seq(1, 5, length = 41)
145
yl <- expression(e^{-frac(1,2) * {log[10](x)}^2})
145
yl <- expression(e^{-frac(1,2) * {log[10](x)}^2})
146
y <- exp(-.5*lx^2)
146
y <- exp(-.5*lx^2)
147
op <- par(mfrow = c(2,1), mar = par("mar")+c(0,1,0,0))
147
op <- par(mfrow = c(2,1), mar = par("mar")+c(0,1,0,0))
148
plot(10^lx, y, log = "xy", type = "l", col = "purple",
148
plot(10^lx, y, log = "xy", type = "l", col = "purple",
149
     main = "Log-Log plot", ylab = yl, xlab = "x")
149
     main = "Log-Log plot", ylab = yl, xlab = "x")
150
plot(10^lx, y, log = "xy", type = "o", pch = '.', col = "forestgreen",
150
plot(10^lx, y, log = "xy", type = "o", pch = ".", col = "forestgreen",
151
     main = "Log-Log plot with custom axes", ylab = yl, xlab = "x",
151
     main = "Log-Log plot with custom axes", ylab = yl, xlab = "x",
152
     axes = FALSE, frame.plot = TRUE)
152
     axes = FALSE, frame.plot = TRUE)
153
my.at <- 10^(1:5)
153
my.at <- 10^(1:5)
154
axis(1, at = my.at, labels = formatC(my.at, format = "fg"))
154
axis(1, at = my.at, labels = formatC(my.at, format = "fg"))
155
at.y <- 10^(-5:-1)
155
at.y <- 10^(-5:-1)