[R] Histograms rotated, side-by-side
Frank E Harrell Jr
fharrell at virginia.edu
Mon May 13 20:52:08 CEST 2002
If you want them exactly back to back see the histbackback function in the Hmisc library. -Frank Harrell
On Mon, 13 May 2002 11:18:07 +0200 (CEST)
Ott Toomet <siim at obs.ee> wrote:
> On Mon, 13 May 2002, Rachel Cunliffe wrote:
>
> |Hi there,
> |
> |I am wanting to create 8 side-by-side histograms which have been rotated 90
> |degrees clockwise from how they usually sit.. all with the same scales. Is
> |someone able to help me out?
>
> I do not know any histogram function which can display horizontal histogram.
> You have to do a workaround using barplot(horis=TRUE). E.g. define a
> function like this:
>
> horiz.hist <- function(x) {
> a <- hist(x, plot=FALSE)
> barplot(a$density, space=0, horiz=TRUE)
> width <- a$breaks[2] - a$breaks[1]
> axis(2, at=(pretty(a$breaks) - a$breaks[1])/width,
> labels=pretty(a$breaks))
> }
>
> And now you can say
>
> > par(mfrow=c(1,8))
> > for(i in 1:8) horiz.hist(rnorm(100))
>
> It works for me. You may consider playing further to get equal scale for
> all the histograms.
>
> Cheers,
>
> Ott
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
--
Frank E Harrell Jr Prof. of Biostatistics & Statistics
Div. of Biostatistics & Epidem. Dept. of Health Evaluation Sciences
U. Virginia School of Medicine http://hesweb1.med.virginia.edu/biostat
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list