Re: [R] Histogram without common borders

From: Thomas Petzoldt <thpe_at_hhbio.wasser.tu-dresden.de>
Date: Tue 20 Jul 2004 - 15:52:06 EST

Ross Darnell wrote:
> Is it possible to produce a histogram directly using the hist()
> function with the common borders removed?
>
> It can be done by plotting the histogram object using type 's'teps.
>
> my.hist <- hist(x,plot=FALSE)
> plot(my.hist$breaks,c(0,my.hist$counts),type='s')

Hello Ross,

I think, your approach is not too bad, however you should use "S" instead of "s", see:

my.hist <- hist(x, lty=1)
lines(my.hist$breaks,c(0, my.hist$counts),

       type='S', lty="dotted", col="red")

avoiding unwanted vertical lines with:

my.hist <- hist(x, lty=0)
lines(c(my.hist$breaks, max(my.hist$breaks)),

       c(0,my.hist$counts,0), type='S')

OR simply use filled bars:

hist(x, col="grey", lty=0)

Hope it helps

Thomas P.



R-help@stat.math.ethz.ch mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html Received on Tue Jul 20 15:58:44 2004

This archive was generated by hypermail 2.1.8 : Wed 03 Nov 2004 - 22:55:05 EST