\Header{barplot}{Bar Plots}
\keyword{hplot}{barplot}
\begin{Usage}
\begin{verbatim}
barplot(height, width = 1, space = NULL, names.arg = NULL,
        legend.text = NULL, beside = FALSE, horiz = FALSE,
        col = heat.colors(NR), border = par("fg"), main = NULL,
        xlab = NULL, ylab = NULL, xlim = NULL, ylim = NULL,
        axes = TRUE, ...)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\texttt{height}] either a vector or matrix of values describing the bars
which make up the plot.  If \texttt{height} is a vector, the plot
consists of a sequence of rectangular bars with heights given by the
values in the vector.  If \texttt{height} is a matrix and
\texttt{beside} is \texttt{FALSE} then each bar of the plot corresponds
to a column of \texttt{height}, with the values in the column giving
the heights of stacked ``sub-bars'' making up the bar. If
\texttt{height} is a matrix and \texttt{beside} is \texttt{TRUE}, then the
values in each column are juxtaposed rather than stacked.
\item[\texttt{width}] optional vector of bar widths.
\item[\texttt{space}] the amount of space (as a fraction of the average bar
width) left before each bar.  May be given as a single number or one
number per bar.  If \texttt{height} is a matrix and \texttt{beside} is
\texttt{TRUE}, \texttt{space} may be specified by two numbers, where the
first is the space between bars in the same group, and the second
the space between the groups.  If not given explicitly, it defaults
to \texttt{c(0,1)} if \texttt{height} is a matrix and \texttt{beside} is
\texttt{TRUE}, and to 0.2 otherwise.
\item[\texttt{names.arg}] a vector of names to be plotted below each bar or
group of bars.  If this argument is omitted, then the names are
taken from the \texttt{names} attribute of \texttt{height} if this is a
vector, or the column names of \texttt{height} if this is a matrix.
\item[\texttt{legend.text}] a vector of text used to construct a legend for the
plot.  This is only useful when \texttt{height} is a matrix.  In that
case the legend labels should correspond to the rows of
\texttt{height}.
\item[\texttt{beside}] a logical value.  If \texttt{FALSE}, the columns of
\texttt{height} are portrayed as stacked bars, and if \texttt{TRUE} the
columns are portrayed as juxtaposed bars.
\item[\texttt{horiz}] a logical value.  If \texttt{FALSE}, the bars are drawn
vertically with the first bar to the left.  If \texttt{TRUE}, the bars
are drwan horizontally with the first at the bottom.
\item[\texttt{col}] a vector of colors for the bars or bar components.
\item[\texttt{border}] the color to be used for the border of the bars.
\item[\texttt{main}] an overall title for the plot.
\item[\texttt{xlab}] a label for the x axis.
\item[\texttt{ylab}] a label for the y axis.
\item[\texttt{xlim}] limits for the x axis.
\item[\texttt{ylim}] limits for the y axis.
\item[\texttt{axes}] logical.  If \texttt{TRUE}, a vertical axis is drawn.
\item[\texttt{...}] further arguments are passed to \texttt{title(.)}.
\end{ldescription}
\end{Arguments}
\begin{Value}
A numeric vector, giving the coordinates of the bar midpoints drawn,
useful for adding to the graph.\end{Value}
\begin{SeeAlso}
\texttt{\Link{plot}(...,type="h")},
\texttt{\Link{dotplot}}, \texttt{\Link{hist}}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
tN <- table(Ni <- rpois(100, lambda=5))
r <- barplot(tN, col='gray')
points(r, tN, type='h', col='red', lwd=2)#- type = "h" plotting *is* `bar'plot

data(deaths, package = "base")
mp <- barplot(deaths) # default
tot <- apply(deaths,2,sum); text(mp, tot + 3, format(tot))
barplot(deaths, beside = TRUE,
        col = c("lightblue", "mistyrose", "lightcyan",
                "lavender", "cornsilk"),
        legend = rownames(deaths), ylim = c(0, 100))
title(main = "Death Rates in Virginia", font.main = 4)

barplot(t(deaths)[, 5:1], beside = TRUE,
        col = c("lightblue", "mistyrose",
                "lightcyan", "lavender"),
        legend = colnames(deaths), ylim = c(0,80),
        main = "Death Rates in Virginia", font.main = 4)
        ## instead of title(.)
\end{ExampleCode}
\end{Examples}

