Re: [R] Subplot.

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

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



R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html 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 https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.