######################################################################## # # John W. Emerson # Department of Statistics # Yale University # # Walton Green # Department of Geology and Geophysics # Yale University # # John Hartigan # Department of Statistics # Yale University # ######################################################################## ######################################################################## ## Copyright (C) 2006 John W. Emerson ## ## This document is free software; you can redistribute it and/or modify ## it under the terms of the GNU General Public License as published by ## the Free Software Foundation; either version 2, or (at your option) ## any later version. ## ## This program is distributed in the hope that it will be useful, but ## WITHOUT ANY WARRANTY; without even the implied warranty of ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU ## General Public License for more details. ## ## A copy of the GNU General Public License is available via WWW at ## http://www.gnu.org/copyleft/gpl.html. You can also obtain it by ## writing to the Free Software Foundation, Inc., 675 Mass Ave, ## Cambridge, MA 02139, USA. ## ## Bug reports to john.emerson@yale.edu ######################################################################## ######################################################################## # # The barcode plot was (to the best of my knowledge) created by John Hartigan, # who implemented a first version for S-Plus and then R. I created this # second implementation to draw on the similarities to boxplot(), in # particular so the horizontal=TRUE/FALSE option would be available. # ######################################################################## # # Notes: expand for use with formula, S3 method? See boxplot(). # ######################################################################## # barcode package:gpairs R Documentation # # Barcode Plots # # Description: # # Produce barcode plot(s) of the given (grouped) values. # # Usage: # # barcode(x, horizontal=TRUE, nint=100, labelloc="left", axisloc="bottom", # main="", outerlabel=FALSE, ptsize=unit(0.25, "char"), # fontsize=9, newpage=TRUE) # # Arguments: # # x: for specifying data from which the barcodes are to be # produced. Either a numeric vector, or a single list containing # such vectors. 'NA's are allowed in the data. # # horizontal: logical indicating if the barcodes should be horizontal; # default 'TRUE' means horizontal barcodes. # # labelloc: for the location of the factor labels of the barcodes; # default TRUE may also be specified as 'left' or 'top' (having # similar results but relating to the horizontal alignment); # values 'right' or 'bottom' are available. # # axisloc: for the location of the quantitative axis labels; # default TRUE may also be specified as 'left' or 'top' (having # similar results but relating to the horizontal alignment); # values 'right' or 'bottom' are available. # # main: the point title. # # xlab: the axis label for the quantitative measurements. # # outerlabel: default FALSE positions all labels within the viewport; TRUE # forces the barcodes to the edge of the viewport, with the labels # outside the viewport. Used by the generalized pairs plots. # # nint: default 0 uses no "binning" -- the barcode represents the exact # measurements (to the precision of the data set); nint=100 uses roughly # 100 "bins" in constructing the barcode; fewer bins results in a # more traditional histogram-type plot, while more bins produces # a more exaggerated barcode. # # fontsize: for the size of the axis and factor labels. # # ptsize: for the size of the plotted points. # # ptpch: for the type of plotted points. # # newpage: default TRUE creates the barcodes on a new graphics device instead # of adding the plot to the current viewport. # # use.points: default FALSE uses segments instead of points in the histogram-style # display. # # # References: # # See Also: # # Examples: see below ################################################################################ # Make sure you have loaded up the source: source("barcode.txt") # Simulate some data (with rounding to provide clumped data): x <- list(Rounded.2=round(rnorm(500, 2, 1),2), SmallerLevel=c(rnorm(100), rnorm(100,4,1)), LargerBivariateRounded.4=round(c(rnorm(500), rnorm(500,3,1)),4)) x[[1]][1] <- NA # Just to make sure it works with NAs barcode(x) barcode(x, main="Random data, default options") barcode(x, main="Different orientatation", horizontal=FALSE) barcode(x, main="Move the axis to the top", axisloc=FALSE) barcode(x, main="Label the x-axis", xlab="Axis Label") barcode(x, labelloc=FALSE, main="Move factor labels") barcode(x, labelouter=TRUE) # No newpage, for use in gpairs(). barcode(x, labelloc="right", axisloc="bottom", main="Title takes up space", xlab="Axis Label") barcode(x, ptsize=unit(0.1, "char"), main="Smaller points") barcode(x, nint=100, main="Histogram binning")