[R] a way to control xlim in multhist?
Justin Gengler
jgengler at umich.edu
Fri Jan 12 00:59:03 CET 2007
Thanks in advance for any suggestions:
I am using the 'multhist' function in the 'plotrix' package to
display histograms of some variable 'x' given some value of another
variable 'z' -- for example, separate histograms for some variable
according to sex (or another dichotomous) variable. Thus I am using
something like the following:
multhist(list(x[z==1],x[z==0]),...).
This generates histograms well enough, but because one cannot control
the 'xlim' parameter the x-axis labels are very odd (or rather,
strictly speaking, you CAN control it, but doing so does not change
the x-axis value labels in the same way that it would if you were
using the simple 'hist' command). More specifically, the labels
almost always seem to progress in increments of 5 or 0.5, depending
on the scale (see, for example, this graph:
http://addictedtor.free.fr/graphiques/RGraphGallery.php?graph=82).
Moreover, if x is, say, a categorical variable with possible values
of 1 through 5, the x-axis labels will remain in the base-5 form
(e.g., 0.5, 1.5, 2.5, etc.) rather than taking on the various
categorical values, regardless of any xlim specification.
I realize that the issue here is that multhist relies on the
'barplot' function, so I have attempted to hack the xlim change
there. But no dice.
So the bottom line is: is there a way to control x-axis scale and
labeling through xliim when using multhist?
Thanks,
Justin Gengler
Also: for a concrete demonstration of what I mean, compare the following:
#1
mh <- list(rnorm(200, mean=100, sd=10), rnorm(200, mean=100, sd=10))
multhist(mh)
#2
multhist(mh,xlim=c(0,20))
More information about the R-help
mailing list