chart.StackedBar(w, colorset = NULL, space = 0.2, cex.axis = 0.8, cex.legend = 0.8, cex.lab = 1, cex.labels = 0.8, cex.main = 1, xaxis = TRUE, legend.loc = "under", element.color = "darkgray", unstacked = TRUE, xlab = "Date", ylab = "Value", ylim = NULL, date.format = "%b %y", major.ticks = "auto", minor.ticks = TRUE, las = 0, xaxis.labels = NULL, ...)
barplot
. Default is 0.2.plot
.plot
.chart.TimeSeries
. The default, "under," is the only location
currently implemented for this chart. Use 'NULL' to remove the legend.plot
plot
par
. Defaults to '3'.barplot
.barplot
but adds three
additional capabilities. First, it calculates and sets a bottom margin for
long column names that are rotated vertically. That doesn't always result
in the prettiest chart, but it does ensure readable labels.Second, it places a legend "under" the graph rather than within the bounds of the chart (which would obscure the data). The legend is created from the column names. The default is to create the legend when there's more than one row of data being presented. If there is one row of data, the chart may be "unstacked" and the legend removed.
Third, it plots or stacks negative values from an origin of zero, similar to
the behavior of barchart
from the 'lattice' package.
Tufte, Edward R. (2001) The Visual Display of Quantitative Information, 2nd edition. The Graphics Press, Cheshire, Connecticut. See http://www.edwardtufte.com for this and other references.
barplot
, par
data(weights)
head(weights)
# With the legend "under" the chart
chart.StackedBar(weights, date.format="\%Y", cex.legend = 0.7, colorset=rainbow12equal)
# Without the legend
chart.StackedBar(weights, colorset=rainbow12equal, legend.loc=NULL)
# for one row of data, use 'unstacked' for a better chart
chart.StackedBar(weights[1,,drop=FALSE], unstacked=TRUE, las=3)
Run the code above in your browser using DataLab