The R Project SVN R

Rev

Rev 87422 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
42333 ripley 1
% File src/library/graphics/man/plotfactor.Rd
68948 ripley 2
% Part of the R package, https://www.R-project.org
87423 smeyer 3
% Copyright 1995-2024 R Core Team
42333 ripley 4
% Distributed under GPL 2 or later
5
 
27442 ripley 6
\name{plot.factor}
87423 smeyer 7
\alias{plot.factor}
27442 ripley 8
\title{Plotting Factor Variables}
9
\usage{
87423 smeyer 10
\method{plot}{factor}(x, y, legend.text = NULL, ...)
27442 ripley 11
}
12
\arguments{
35539 hornik 13
    \item{x, y}{numeric or factor. \code{y} may be missing.}
48610 ripley 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
61433 ripley 16
      sets the \code{yaxlabels} argument of \code{\link{spineplot}}.}
48610 ripley 17
    \item{\dots}{Further arguments to \code{\link{barplot}},
18
      \code{\link{boxplot}}, \code{\link{spineplot}} or
56113 ripley 19
      \code{\link{plot}} as appropriate.  All of these accept
87423 smeyer 20
      \link{graphical parameters} (see \code{\link{par}}),
56113 ripley 21
      annotation arguments passed
87423 smeyer 22
      to \code{\link{title}}, and \code{axes = FALSE}.  None accept \code{type}.
48610 ripley 23
    }
27442 ripley 24
}
25
\description{
87422 smeyer 26
  This method is used for
27442 ripley 27
  \code{\link{factor}} arguments of the \emph{generic}
87422 smeyer 28
  \code{\link{plot}} function,
87423 smeyer 29
  possibly called from the formula method.
48610 ripley 30
 
87423 smeyer 31
  If \code{y} is missing a \code{\link{barplot}} is produced.
48610 ripley 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
34
  \code{y} the next \code{plot} method is called, normally
35
  \code{\link{plot.default}}.
27442 ripley 36
}
37
\seealso{
38
    \code{\link{plot.default}}, \code{\link{plot.formula}},
35539 hornik 39
    \code{\link{barplot}}, \code{\link{boxplot}}, \code{\link{spineplot}}.
27442 ripley 40
}
41
\examples{
41502 ripley 42
require(grDevices)
87423 smeyer 43
 
44
plot(state.region)
45
 
46
## called from the formula method
47
plot(~ group, data = PlantGrowth)
48
plot(weight ~ group, data = PlantGrowth)           # numeric ~ factor
61168 ripley 49
plot(cut(weight, 2) ~ group, data = PlantGrowth)   # factor ~ factor
35534 hornik 50
## passing "..." to spineplot() eventually:
36816 ripley 51
plot(cut(weight, 3) ~ group, data = PlantGrowth,
52
     col = hcl(c(0, 120, 240), 50, 70))
27442 ripley 53
 
61168 ripley 54
plot(PlantGrowth$group, axes = FALSE, main = "no axes")  # extremely silly
27442 ripley 55
}
56
\keyword{hplot}