Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

squareplot

Create a squareplot alternative to a segmented barplot


Description

Create a squareplot as an alternative to a segmented barplot. Useful when the viewer is interested in exact counts in the categories. A squareplot is often used by the New York Times. A grid of squares is presented with each color representing a different category. The colors appear contiguously reading top to bottom, left to right. The colors segment the graph as a segmented bargraph, but the squares allow an interested reader to easily tally the counts.

Usage

squareplot(x, col = gray(seq(0.5, 1, length = length(x))),
border =NULL, nrows = ceiling(sqrt(sum(x))), ncols =
ceiling(sum(x)/nrows),
...)

Arguments

x

a vector of counts

col

a vector of colors

border

border color passed to polygon

nrows

number of rows

ncols

number of columns

...

passed to title

Value

Creates the graph, but has no return value.

Author(s)

John Verzani

References

The New York Times, www.nytimes.com. In particular, Sports page 6, June 15, 2003.

Examples

## A Roger Clemens Cy Young year -- roids?
squareplot(c(21,7,6),col=c("blue","green","white"))

UsingR

Data Sets, Etc. for the Text "Using R for Introductory Statistics", Second Edition

v2.0-6
GPL (>= 2)
Authors
John Verzani <verzani@math.csi.cuny.edu>
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.