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? Thanks so much, Rachel Cunliffe -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
An alternative solution is to use barchart (after transformation of the
data to get groups and sizes or means). This will ensure that plots are
on the same scale:
library(lattice)
data(barley)
barchart(variety ~ yield | year * site,
data = barley, horizontal = T,
ylab = "Barley Yield (bushels/acre)",
scales = list(x = list(0, abbreviate = TRUE, minlength = 5)))
Best,
Renaud
Ott Toomet 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
>
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
--
Dr Renaud Lancelot, v?t?rinaire
CIRAD, D?partement Elevage et M?decine V?t?rinaire (CIRAD-Emvt)
Programme Productions Animales
http://www.cirad.fr/presentation/programmes/prod-ani.shtml (Fran?ais)
http://www.cirad.fr/presentation/en/program-eng/prod-ani.shtml (English)
ISRA-LNERV tel (221) 832 49 02
BP 2057 Dakar-Hann fax (221) 821 18 79 (CIRAD)
Senegal e-mail renaud.lancelot at cirad.fr
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._