[R] Subplot.
Deepayan Sarkar
deepayan.sarkar at gmail.com
Sat Jul 14 01:25:44 CEST 2007
On 7/13/07, suman Duvvuru <duvvuru.suman at gmail.com> wrote:
> Hello All,
>
> I wanted to do many plots (in my case, wanted to get 6 histograms) on the
> same figure. Is there a method in R that analogous to 'subplot' in MATLAB?
Here are a few possibilities:
data(singer, package = "lattice")
## using traditional graphics
singer.split <- with(singer, split(height, voice.part))
par(mfrow = c(2, 4))
for (i in names(singer.split))
hist(singer.split[[i]], main = i, xlab = "height")
## using lattice
library(lattice)
histogram(~height | voice.part, singer)
## using ggplot2
library(ggplot2)
qplot(height, data = singer, geom = "histogram", facets = voice.part ~ .)
-Deepayan
More information about the R-help
mailing list