r - Make histograms of stacked rectangles rather than columns -


with following code, histogram below

x <- rnorm(100) hist(x,col="gray") 

what can display bars stacked rectangles (visible outlines, rather change in fill color) instead of uniform columns? each rectangle represents frequency of, example, 1, although want able change through parameter.

histogram

here function started (it modicication of part of examples tkbrush function in teachingdemos package):

     rechist <- function(x,...){          tmp <- hist(x,plot=f)          br <- tmp$breaks          w <- as.numeric(cut(x,br,include.lowest=true))          sy <- unlist(lapply(tmp$counts,function(x)seq(length=x)))          <- max(sy)          sy <- sy/my          <- 1/my          sy <- sy[order(order(x))]         plot.new()         plot.window(xlim=range(br), ylim=c(0,1))          rect(br[w], sy-my, br[w+1], sy,              border=true, col='grey')          rect(br[-length(br)], 0, br[-1], tmp$counts*my)         axis(1)      }  rechist( iris$petal.length ) 

Comments

Popular posts from this blog

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -

php - Controller/JToolBar not working in Joomla 2.5 -