[R] color individual bar of histogram?

2008-10-28 Thread Whit Armstrong
Anyone know a quick way to color one bar of a histogram? I want to mark the bar in which the most recent observation falls. So, for instance: x - rnorm(100) latest.ob - x[100] hist(x) ## how do I mark the bucket that latest.ob falls into? Thanks, Whit

Re: [R] color individual bar of histogram?

2008-10-28 Thread Peter Dalgaard
Whit Armstrong wrote: Anyone know a quick way to color one bar of a histogram? I want to mark the bar in which the most recent observation falls. So, for instance: x - rnorm(100) latest.ob - x[100] hist(x) ## how do I mark the bucket that latest.ob falls into? Something like this:

Re: [R] color individual bar of histogram?

2008-10-28 Thread Whit Armstrong
That's great, Peter. Thanks very much. -Whit On Tue, Oct 28, 2008 at 3:13 PM, Peter Dalgaard [EMAIL PROTECTED] wrote: Whit Armstrong wrote: Anyone know a quick way to color one bar of a histogram? I want to mark the bar in which the most recent observation falls. So, for instance: x -

Re: [R] color individual bar of histogram?

2008-10-28 Thread Henrique Dallazuanna
Other option without rect is: h - hist(x, plot = FALSE) bin - as.numeric(cut(latest.ob, h$breaks)) plot(h, col = replace(rep(white, length(h$breaks) - 1), bin, red)) On Tue, Oct 28, 2008 at 4:48 PM, Whit Armstrong [EMAIL PROTECTED]wrote: Anyone know a quick way to color one bar of a histogram?

Re: [R] color individual bar of histogram?

2008-10-28 Thread Peter Dalgaard
Henrique Dallazuanna wrote: Other option without rect is: h - hist(x, plot = FALSE) bin - as.numeric(cut(latest.ob, h$breaks)) plot(h, col = replace(rep(white, length(h$breaks) - 1), bin, red)) Nice. Some small improvements seem possible: h - hist(x, plot = FALSE) bin - cut(latest.ob,