The R Project SVN R

Rev

Rev 87422 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 87422 Rev 87423
Line 1... Line 1...
1
% File src/library/graphics/man/plotfactor.Rd
1
% File src/library/graphics/man/plotfactor.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-2009 R Core Team
3
% Copyright 1995-2024 R Core Team
4
% Distributed under GPL 2 or later
4
% Distributed under GPL 2 or later
5
 
5
 
6
\name{plot.factor}
6
\name{plot.factor}
-
 
7
\alias{plot.factor}
7
\title{Plotting Factor Variables}
8
\title{Plotting Factor Variables}
8
\usage{
9
\usage{
9
\method{plot}{factor}(x, y, legend.text = NULL, \dots)
10
\method{plot}{factor}(x, y, legend.text = NULL, ...)
10
}
11
}
11
\alias{plot.factor}
-
 
12
\arguments{
12
\arguments{
13
    \item{x, y}{numeric or factor. \code{y} may be missing.}
13
    \item{x, y}{numeric or factor. \code{y} may be missing.}
14
    \item{legend.text}{character vector for annotation of y axis in the
14
    \item{legend.text}{character vector for annotation of y axis in the
15
      case of a factor \code{y}: defaults to \code{levels(y)}.  This
15
      case of a factor \code{y}: defaults to \code{levels(y)}.  This
16
      sets the \code{yaxlabels} argument of \code{\link{spineplot}}.}
16
      sets the \code{yaxlabels} argument of \code{\link{spineplot}}.}
17
    \item{\dots}{Further arguments to \code{\link{barplot}},
17
    \item{\dots}{Further arguments to \code{\link{barplot}},
18
      \code{\link{boxplot}}, \code{\link{spineplot}} or
18
      \code{\link{boxplot}}, \code{\link{spineplot}} or
19
      \code{\link{plot}} as appropriate.  All of these accept
19
      \code{\link{plot}} as appropriate.  All of these accept
20
      \link{graphical parameters} (see \code{\link{par}}) and
20
      \link{graphical parameters} (see \code{\link{par}}),
21
      annotation arguments passed
21
      annotation arguments passed
22
      to \code{\link{title}} and \code{axes = FALSE}.  None accept \code{type}.
22
      to \code{\link{title}}, and \code{axes = FALSE}.  None accept \code{type}.
23
    }
23
    }
24
}
24
}
25
\description{
25
\description{
26
  This method is used for
26
  This method is used for
27
  \code{\link{factor}} arguments of the \emph{generic}
27
  \code{\link{factor}} arguments of the \emph{generic}
28
  \code{\link{plot}} function,
28
  \code{\link{plot}} function,
29
  possibly called from the formula method (see the Examples).
29
  possibly called from the formula method.
30
 
30
 
31
  If \code{y} is missing \code{\link{barplot}} is produced.
31
  If \code{y} is missing a \code{\link{barplot}} is produced.
32
  For numeric \code{y} a \code{\link{boxplot}} is used, and for a factor
32
  For numeric \code{y} a \code{\link{boxplot}} is used, and for a factor
33
  \code{y} a \code{\link{spineplot}} is shown.  For any other type of
33
  \code{y} a \code{\link{spineplot}} is shown.  For any other type of
34
  \code{y} the next \code{plot} method is called, normally
34
  \code{y} the next \code{plot} method is called, normally
35
  \code{\link{plot.default}}.
35
  \code{\link{plot.default}}.
36
}
36
}
Line 38... Line 38...
38
    \code{\link{plot.default}}, \code{\link{plot.formula}},
38
    \code{\link{plot.default}}, \code{\link{plot.formula}},
39
    \code{\link{barplot}}, \code{\link{boxplot}}, \code{\link{spineplot}}.
39
    \code{\link{barplot}}, \code{\link{boxplot}}, \code{\link{spineplot}}.
40
}
40
}
41
\examples{
41
\examples{
42
require(grDevices)
42
require(grDevices)
-
 
43
 
-
 
44
plot(state.region)
-
 
45
 
43
% this does not call plot.factor!
46
## called from the formula method
44
% plot(PlantGrowth)                                # -> plot.data.frame
47
plot(~ group, data = PlantGrowth)
45
plot(weight ~ group, data = PlantGrowth)           # numeric vector ~ factor
48
plot(weight ~ group, data = PlantGrowth)           # numeric ~ factor
46
plot(cut(weight, 2) ~ group, data = PlantGrowth)   # factor ~ factor
49
plot(cut(weight, 2) ~ group, data = PlantGrowth)   # factor ~ factor
47
## passing "..." to spineplot() eventually:
50
## passing "..." to spineplot() eventually:
48
plot(cut(weight, 3) ~ group, data = PlantGrowth,
51
plot(cut(weight, 3) ~ group, data = PlantGrowth,
49
     col = hcl(c(0, 120, 240), 50, 70))
52
     col = hcl(c(0, 120, 240), 50, 70))
50
 
53