Message-ID: <OF5F9DCBE9.BC46012C-ON802575B4.00305289-802575B4.0030C3CE@hsl.gov.uk>
Date: 2009-05-12T08:52:20Z
From: Richard Cotton
Subject: lattice histogram for multiple variables : adjusting x axis
In-Reply-To: <1DF7DB4AB44EFB41A60A889186D4335931FB3F@srv-laminiere.arvalis-fr.com>
> I have a large data frame and I want to look at the distribution of
> each variable very quickly by plotting an individual histogram for
> each variable.
> I'd like to do so using lattice.
>
> Here is a small example using the iris data set:
>
> histogram(as.formula(paste("~",paste(colnames(iris[,!sapply(iris,is.
> factor)]),collapse="+"))),data=iris[,!sapply(iris,is.factor)])
>
> However in this graphic, the x-axis and the breaks are the same for
> all 4 variables. I would like them to be adjusted to the data in
> each panel separately. I have tried using the scales argument to no
avail:
>
> histogram( as.formula(paste("~",paste(colnames(iris[,!sapply(iris,
> is.factor)]),collapse="+"))) ,data=iris[,!sapply(iris,is.factor)],
> scales=list(x=list(relation="free")) )
>
>
> How can I individualize the x-axis and breaks for each individual panel?
You're on the right track. If you don't specify a breaks argument, then
histogram calculates a common axis and breaks across all the panels.
Declaring breaks=NULL will force it to calculate them for each panel.
histogram(
as.formula(paste("~",paste(colnames(iris[,!sapply(iris,is.factor)]),collapse="+"))),
data=iris[,!sapply(iris,is.factor)],
scales=list(x=list(relation="free")),
breaks=NULL
)
You can also specify a hist-style method, e.g. breaks="Sturges" to get
what you want.
Regards,
Richie.
Mathematical Sciences Unit
HSL
------------------------------------------------------------------------
ATTENTION:
This message contains privileged and confidential inform...{{dropped:20}}