Description Usage Arguments Details Value Author(s) See Also Examples
Hist generates a histogram with better (IMNSHO) defaults than the
hist
() function.
1 2 3 4 5 6 7 8 9 |
x |
Numeric vector of values to be histogramed. |
breaks |
one of:
In the last three cases the number is a suggestion only; as the
breakpoints will be set to |
ylog |
Logical or numeric, controlling whether y-axis is logged. If TRUE,
|
xlab, ylab |
Character values; labels for the x- and y-axes |
bound |
Logical value. If TRUE, values outside the range of breaks are added to the extreme bins; otherwise, they are excluded. Ignored if length(breaks)==1. |
... |
Other plotting arguments passed to |
The behavior of Hist() is very similar to hist
(),
but with the following differences:
Values may be outside the range of the breaks specified (bound argument determines how they are handled).
By default, the bars are gray.
The axes extend to the limits of the plot, and are not displaced from the plot.
Permits you to plot the log counts via the ylog argument.
The optional "add" argument, if true, prevents labels or axes from
being drawn. To make this work, you should pass
breaks=this.hist$breaks
from the previous call in order to use
the same bins.
If the optional argument horiz=TRUE, the bars will be plotted horizontally. The y-axis will then be treated as the x- and vice versa with regards to labeling, limits, etc. (i.e., xlabel will be used to label the y-axis). Note that the names of the list returned are also "flipped", so that this.hist$ylim is really the y-axis limits, etc.
Returns a histogram object, like what is returned by the
hist
function, but with additional elements:
xbin (or ybin if horiz=T): A function that accepts a single argument. If numeric, the values are converted to bin number. This allows you to add more lines, points, etc to the plot, by passing x.bin(x) instead of x to the plotting function.
xlim: x-axis limits of plot ("true" limits, in bins; to
get the limits in terms of the input data, use:
range(this.hist$breaks))
.
ylim: y-axis limits of the plot.
xname, yname: character string with the x- and y-labels.
logcounts: The logged counts + 1, in the base specified (only if ylog argument is not FALSE).
logbase: The base used for logcounts.
M.W.Rowe, mwr.stats@gmail.com
plot.default
, par
,
axis
for more details about plotting options, as
well as barplot
and hist
,
1 2 3 4 5 6 7 8 | # plot normally distributed random numbers, with y-axis logged
this.hist <- Hist(rnorm(10000), 40, ylog=TRUE)
# vertical lines at +/-2
abline(v=this.hist$xbin(c(-2, 2)), col="red", lty=3, lwd=2)
# plot it again, without logging the y-axis
this.hist <- Hist(rnorm(10000), 40)
# for comparison, look at the standard histogram function
plot(this.hist)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.