Mighty thanks Peter. This does precisely what I wanted.
Thanks again.

On Mon, Mar 14, 2011 at 4:52 PM, Peter Langfelder <
peter.langfelder@gmail.com> wrote:

> On Mon, Mar 14, 2011 at 1:06 PM, Pavan G <pavan.namd@gmail.com> wrote:
> > Hello All,
> > I have a histogram with values above and below 0. I would like to color
> the
> > +ve bars green and -ve bars red. I am plotting data using:
> >
> > hist(a[,2],breaks=100,main="W3",xlab="Movement towards site (A)")
> >
> > Can someone please comment on how it can be done?
> > Thanks!
>
> See help(hist). The argument "border" lets you color the outline of
> the bars. You can use, for example, this code:
>
> h = hist(a[,2],breaks=100)
> bor = ifelse(h$mids < 0, "red", "green");
> plot(h, border = bor, main="W3",xlab="Movement towards site (A)")
>
> Example with random data:
>
> h = hist(rnorm(1000),breaks=100)
> bor = ifelse(h$mids < 0, "red", "green");
> plot(h, border = bor, main="W3",xlab="Movement towards site (A)")
>
> HTH,
>
> Peter
>

	[[alternative HTML version deleted]]

