Dear all, It's fairly straightforward to plot cumulative histograms using the hist() function. You do something like:
h <- hist(rnorm(100), plot=FALSE) h$counts<- cumsum(h$counts) plot(h) However, I have failed to find any example where this is done using the lattice histogram() function. I realize I need to slightly alter the panel function panel.histogram. Specifially I would like to add the following line in red, just like I did above: function (x, breaks, equal.widths = TRUE, type = "density", nint = round(log2(length(x)) + 1), alpha = plot.polygon$alpha, col = plot.polygon$col, border = plot.polygon$border, lty = plot.polygon$lty, lwd = plot.polygon$lwd, ...) { plot.polygon <- trellis.par.get("plot.polygon") xscale <- current.panel.limits()$xlim panel.lines(x = xscale[1] + diff(xscale) * c(0.05, 0.95), y = c(0, 0), col = border, lty = lty, lwd = lwd, alpha = alpha) if (length(x) > 0) { if (is.null(breaks)) { breaks <- if (is.factor(x)) seq_len(1 + nlevels(x)) - 0.5 else if (equal.widths) do.breaks(range(x, finite = TRUE), nint) else quantile(x, 0:nint/nint, na.rm = TRUE) } h <- hist.constructor(x, breaks = breaks, ...) h$counts<- cumsum(h$counts) y <- if (type == "count") h$counts else if (type == "percent") 100 * h$counts/length(x) else h$intensities breaks <- h$breaks nb <- length(breaks) if (length(y) != nb - 1) warning("problem with 'hist' computations") if (nb > 1) { panel.rect(x = breaks[-nb], y = 0, height = y, width = diff(breaks), col = col, alpha = alpha, border = border, lty = lty, lwd = lwd, just = c("left", "bottom")) } } } <environment: namespace:lattice> My problem is I'm too unexperienced in handling these panel functions to achieve this. Simply copying the panel function, appending the line, and giving it another name obviously doesn't work (it won't find the function hist.constructor). I would very much appreciate help on how this could be done, or some other way to draw cumulative lattice histograms. Thanks in advance, Ola Caster [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.