# generate 100 random normal data values
y <- rnorm(100)
# histogram with all defaults
color.hist(y)
# histogram with specified bins and grid lines displayed over the histogram
color.hist(y, breaks=seq(-5,5,.25), xlab="My Variable", over.grid=TRUE)
# histogram with bins calculated with the Scott method and values displayed
color.hist(y, breaks="Scott", show.values=TRUE)
# histogram with the number of suggested bins, with proportions
color.hist(y, breaks=25, prop=TRUE)
# histogram with specified colors, overriding defaults
# col.bg and col.grid are defined in color.hist
# all other parameters are defined in hist, par and plot functions
color.hist(y, col="darkblue", border="lightsteelblue4", col.bg="ivory",
col.grid="darkgray", density=25, angle=-45, cex.lab=.8, cex.axis=.8,
col.lab="sienna3", main="My Title", col.main="gray40", xlim=c(-5,5), lwd=2)
# cumulative histogram with superimposed regular histogram, all defaults
color.hist(y, cumul="both")
# cumulative histogram plus regular histogram
# present with proportions on vertical axis, override other defaults
color.hist(y, cumul="both", breaks=seq(-4,4,.25), prop=TRUE,
col.reg="mistyrose")
Run the code above in your browser using DataLab