TwoBar

A quick and dirty little function to plot two vectors on the same barplot.
A quick and dirty little function to plot two vectors on the same barplot.

Documentation

twobar(a,b,space=2,breaks="auto",AL=0.5,nameA="A",nameB="B",xl="",yl="",mn="",legx="topright")

#a and b are two vectors

# space is the fold increase in breaks for histograms.
# e.g. if you want twice has many breaks as R will pick, space=2

#legx can be any of the options for legend

#xl, yl, and mn are titles for the x axis, y axis, and main

#nameA and nameB are the names you want to appear in the legend

# AL is the alpha setting for transparency
# set AL to 1 for x11, and AL to <1 for transparency on a pdf

#breaks are automatically calculated by default, but user-specified breaks can be added

Example

The code produces the graphs below:
twobar(rnorm(10000),rnorm(10000,mean=1),space=1,mn="two normals",yl="density",xl="mean",nameA=expression(paste(mu, " = 0")),nameB=expression(paste(mu, " = 1")))

twobar(runif(10000,0,5),rgamma(10000,3,2),space=2,mn="uniform and a gamma",yl="density",xl="mean",nameB=expression(paste(gamma, "(3,2)")),nameA="U(0,3)")


uniform and a gamma two normals

Code twobar.txt