chart.StackedBar(w, colorset = NULL, space = 0.2, cex.legend = 0.8, cex.names = 1, cex.axis = 1, las=3, legend.loc="under", element.color = "darkgray", unstacked = TRUE, xlab=NULL, ylim=NULL, ... )
barplot
. Default is 0.2.plot
.barplot
.plot
.par
. Defaults to '3'.chart.TimeSeries
. The default, "under," is the only location currently implemented for this chart. Use 'NULL' to remove the legend.plot
barplot
. These can include further arguments (such as 'axes', 'asp' and 'main') and graphical parameters (see 'par') which are passed to 'plot.window()', 'title()' and 'axis'.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, legend.cex = 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)
Run the code above in your browser using DataLab