An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120223/0db6a5d8/attachment.pl>
multhist weird behavior/ xlabels wrong
3 messages · Laura Matrajt, Jim Lemon
On 02/24/2012 09:30 AM, Laura Matrajt wrote:
Hi, I found some weird behavior of the function multhist in the plotrix package and I would like to ask you about it: so, it works well to put two histograms next to each other, but I don't understand the breaks? so for example, library(plotrix) mh<- list(rnorm(200, mean=100, sd=10), rnorm(200, mean=100, sd=10)) multhist(mh) #produces a plot with 12 bins multhist(mh, breaks=2) #produces a plot with 2 bins, as expected multhist(mh, breaks=3) #produces a plot with 4 bins??? multhist(mh, breaks=4) #produces a plot with 4 bins multhist(mh, breaks=7) #produces a plot with 6 bins??? etc. So odd number of breaks doesn't seem to work, and even more, some times it does the lowest even number of bins (so if I put breaks=7 I will get 6 bins) but other times it does the highest even number of bins (so if I put breaks=3 I get 4 bins) In addition, things become even worse when you try to add labels to the bins. So, all this to say that I am trying to put two histograms side to side, and put some correct number of bins and labels? does anyone have an idea of how to do this?
Hi Laura, This may be due to the way breaks are calculated when you just specify a suggested number of bins. However, when I tried this with barp: mhmat<-rbind(table(cut(mh[[1]],breaks=3)), table(cut(mh[[2]],breaks=3))) library(plotrix) barp(mhmat) I got what I expected, three groups of two bars. Perhaps this will do what you want. Jim
An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20120224/e4a9a166/attachment.pl>