Re: [R] Subplot.

From: Deepayan Sarkar <>
Date: Fri, 13 Jul 2007 16:25:44 -0700

On 7/13/07, suman Duvvuru <> 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

histogram(~height | voice.part, singer)

## using ggplot2

qplot(height, data = singer, geom = "histogram", facets = voice.part ~ .)

-Deepayan mailing list PLEASE do read the posting guide and provide commented, minimal, self-contained, reproducible code. Received on Fri 13 Jul 2007 - 23:36:33 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 14 Jul 2007 - 00:33:02 GMT.

Mailing list information is available at Please read the posting guide before posting to the list.