Skip to content

For two vectors, how to plot bin-to-bin histogram comparision in R?

2 messages · arun, Bert Gunter

#
Hi,
Try ?multhist() from library(plotrix)
set.seed(49)
?vec1 <- rnorm(1e4,0,0.5)
?set.seed(9453)
?vec2 <- rnorm(1e4,0,0.5)
library(plotrix)
multhist(list(vec1,vec2))
A.K.





I've met a problem recently. Have you ever been met a plot like the belowing? 



In
 this picture, as you see, the solid black bars represent one vector 
(named as vector A), and the empty bars represent the other vector 
(named as vector B). I know how to plot two histogram together in one 
picture. however, I don't know how to draw and compare them in 
bin-to-bin form just like the above picture. Did anybody know how to 
plot this in R?
#
Of course the OP failed to note that no pictures can come through...

But anyway,

Do not do this!  It can be highly misleading (due to arbitrariness of
binning). See

?qqplot

for a much better way to compare distributions.(alas, rarely used
except by statisticians)

-- Bert








Bert Gunter
Genentech Nonclinical Biostatistics
(650) 467-7374

"Data is not information. Information is not knowledge. And knowledge
is certainly not wisdom."
H. Gilbert Welch
On Fri, Feb 14, 2014 at 7:30 PM, arun <smartpink111 at yahoo.com> wrote: