#' Plot \code{histogram} object
#'
#' A a very minor modification of \code{graphics::plot.histogram}. \cr
#' Only difference is that \code{lwd} now specifies the width of the histogram bars'
#' outline.
#'
#' @usage NULL
#'
#' @seealso
#' \code{\link[graphics]{plot.histogram}}, \code{\link{plot.stl}},
#' \code{\link{ahist}}
#'
#' @export
plot.histogram <- function(x, freq=equidist, density=NULL, angle=45, col=NULL,
border = par("fg"), lty = NULL, lwd=1, main = paste("Histogram of",
paste(x$xname, collapse = "\n")), sub = NULL, xlab = x$xname,
ylab, xlim = range(x$breaks), ylim = NULL, axes = TRUE, labels = FALSE,
add = FALSE, ann = TRUE, ...) {
equidist <- if (is.logical(x$equidist))
x$equidist
else {
h <- diff(x$breaks)
diff(range(h)) < 1e-07 * mean(h)
}
if (freq && !equidist)
warning("the AREAS in the plot are wrong -- rather use 'freq = FALSE'")
y <- if (freq)
x$counts
else x$density
nB <- length(x$breaks)
if (is.null(y) || 0L == nB)
stop("'x' is wrongly structured")
dev.hold()
on.exit(dev.flush())
if (!add) {
if (is.null(ylim))
ylim <- range(y, 0)
if (missing(ylab))
ylab <- if (!freq)
"Density"
else "Frequency"
plot.new()
plot.window(xlim, ylim, "", ...)
if (ann)
title(main = main, sub = sub, xlab = xlab, ylab = ylab,
...)
if (axes) {
axis(1, ...)
axis(2, ...)
}
}
rect(x$breaks[-nB], 0, x$breaks[-1L], y, col = col, border = border,
angle = angle, density = density, lty = lty, lwd = lwd)
if ((logl <- is.logical(labels) && labels) || is.character(labels))
text(x$mids, y, labels = if (logl) {
if (freq)
x$counts
else round(x$density, 3)
}
else labels, adj = c(0.5, -0.5))
invisible()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.