| Barplot | R Documentation |
Bar Plots
Barplot(
x,
by,
scale = c("frequency", "percent"),
conditional = TRUE,
style = c("divided", "parallel"),
col = if (missing(by)) "gray" else rainbow_hcl(length(levels(by))),
xlab = deparse(substitute(x)),
legend.title = deparse(substitute(by)),
ylab = scale,
main = NULL,
legend.pos = "above",
label.bars = FALSE,
...
)
x |
a factor (or character or logical variable). |
by |
optionally, a second factor (or character or logical variable). |
scale |
either |
conditional |
if |
style |
for two-factor plots, either |
col |
if |
xlab |
an optional character string providing a label for the horizontal axis. |
legend.title |
an optional character string providing a title for the legend. |
ylab |
an optional character string providing a label for the vertical axis. |
main |
an optional main title for the plot. |
legend.pos |
position of the legend, in a form acceptable to the |
label.bars |
if |
... |
arguments to be passed to the |
Create bar plots for one or two factors scaled by frequency or precentages.
In the case of two factors, the bars can be divided (stacked) or plotted in parallel (side-by-side).
This function is a front end to barplot in the graphics package.
Invisibly returns the horizontal coordinates of the centers of the bars.
John Fox
barplot, legend, rainbow_hcl
with(Mroz, Barplot(wc))
with(Mroz, Barplot(wc, col="lightblue", label.bars=TRUE))
with(Mroz, Barplot(wc, by=hc))
with(Mroz, Barplot(wc, by=hc, scale="percent", label.bars=TRUE))
with(Mroz, Barplot(wc, by=hc, style="parallel", scale="percent", legend.pos="center"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.