The R Project SVN R

Rev

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

Rev 83419 Rev 87729
Line 1... Line 1...
1
% File src/library/graphics/man/matplot.Rd
1
% File src/library/graphics/man/matplot.Rd
2
% Part of the R package, https://www.R-project.org
2
% Part of the R package, https://www.R-project.org
3
% Copyright 1995-2022 R Core Team
3
% Copyright 1995-2025 R Core Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
 
5
 
6
\name{matplot}
6
\name{matplot}
7
\alias{matplot}
7
\alias{matplot}
8
\alias{matpoints}
8
\alias{matpoints}
Line 140... Line 140...
140
matpoints(iris[iV,c(1,3)], iris[iV,c(2,4)], pch = "vV", col = c(2,4))
140
matpoints(iris[iV,c(1,3)], iris[iV,c(2,4)], pch = "vV", col = c(2,4))
141
legend(1, 4, c("    Setosa Petals", "    Setosa Sepals",
141
legend(1, 4, c("    Setosa Petals", "    Setosa Sepals",
142
               "Versicolor Petals", "Versicolor Sepals"),
142
               "Versicolor Petals", "Versicolor Sepals"),
143
       pch = "sSvV", col = rep(c(2,4), 2))
143
       pch = "sSvV", col = rep(c(2,4), 2))
144
 
144
 
145
nam.var <- colnames(iris)[-5]
-
 
146
nam.spec <- as.character(iris[1+50*0:2, "Species"])
-
 
147
iris.S <- array(NA, dim = c(50,4,3),
-
 
148
                dimnames = list(NULL, nam.var, nam.spec))
-
 
149
for(i in 1:3) iris.S[,,i] <- data.matrix(iris[1:50+50*(i-1), -5])
-
 
150
 
-
 
151
matplot(iris.S[, "Petal.Length",], iris.S[, "Petal.Width",], pch = "SCV",
145
matplot(iris3[, "Petal L.",], iris3[, "Petal W.",], pch = "SCV",
152
        col = rainbow(3, start = 0.8, end = 0.1),
146
        col = rainbow(3, start = 0.8, end = 0.1),
153
        sub = paste(c("S", "C", "V"), dimnames(iris.S)[[3]],
147
        sub = paste(c("S", "C", "V"), dimnames(iris3)[[3]],
154
                    sep = "=", collapse= ",  "),
148
                    sep = "=", collapse= ",  "),
155
        main = "Fisher's Iris Data")
149
        main = "Fisher's Iris Data")
156
par(op)
150
par(op)
157
 
151
 
158
## 'x' a "Date" vector :
152
## 'x' a "Date" vector :
Line 165... Line 159...
165
matplot(ct, mSC, type = "b", main = "matplot(<POSIXct>, y)")
159
matplot(ct, mSC, type = "b", main = "matplot(<POSIXct>, y)")
166
## or the same with even more axis flexibility:
160
## or the same with even more axis flexibility:
167
matplot(ct, mSC, type = "b", main = "matplot(<POSIXct>, y)", xaxt="n")
161
matplot(ct, mSC, type = "b", main = "matplot(<POSIXct>, y)", xaxt="n")
168
Axis(ct, side=1, at = ct[1+4*(0:24)])
162
Axis(ct, side=1, at = ct[1+4*(0:24)])
169
 
163
 
-
 
164
iS <- 1:3 # indices of subset
-
 
165
matplot(gait[, iS, 1], gait[, iS, 2], pch = "123", type = "b",
-
 
166
        col = rainbow(3, start = 0.8, end = 0.1),
-
 
167
        sub = paste(iS, dimnames(gait)[[2]][iS],
-
 
168
                    sep = "=", collapse= ",  "),
-
 
169
        xlab = "Hip angle", ylab = "Knee angle",
-
 
170
        main = "Hip and knee angle while walking")
-
 
171
 
170
## Also works for data frame columns:
172
## Also works for data frame columns:
171
matplot(iris[1:50,1:4])
173
matplot(iris[1:50,1:4])
172
}
174
}
173
\keyword{hplot}
175
\keyword{hplot}
174
\keyword{aplot}
176
\keyword{aplot}