Re: [R] Graph Order in xyplot

From: Deepayan Sarkar <deepayan.sarkar_at_gmail.com>
Date: Tue, 01 Jul 2008 15:34:30 -0700

On 7/1/08, Sam Albers <tonightsthenight_at_gmail.com> wrote:
> I have constructed a Trellis style xyplot.
>
> lengthf <- factor(length)
> xyplot(SLI$velocity ~ SLI$width | SLI$lengthf, layout = c(2,7), xlab =
> "Width (cm)", ylab = "Velocity (m/s^2)", col = "black")

As an aside, the recommended incantation is

xyplot(velocity ~ width | lengthf, data = SLI, <etc.>)

> This produces a lovely little plot. However, the grouping factor(lengthf)
> isn't in the right order. My values range from 2-28 and the 2 graph on the
> bottom left and the graphs continue sequentially left to right to the top of
> the page. I would like to have the 2 at the top and have the graphs shown in
> descending order (i.e. have the entire graph read like a book)
>
> I tried the following but it didn't seem to work.
>
> lengthd <-sort(SLI$length, decreasing =TRUE)
> lengthdf <- factor(SLI$lengthd)

This wouldn't do anything new unless you also specify a 'levels' argument in your call to factor().

> Then I plotted the graph again:
> xyplot(SLI$velocity ~ SLI$width | SLI$lengthdf, layout = c(2,7), xlab =
> "Width (cm)", ylab = "Velocity (m/s^2)", col = "black")
>
> This simply gave me the same graph and now I am a little lost. Is there an
> easier way to do this? Do I have to rearrange my data or can this be changed
> around using the original xyplot command line.

Perhaps you are looking for

xyplot(velocity ~ width | lengthf, data = SLI,

       as.table = TRUE, [...])

-Deepayan



R-help_at_r-project.org 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 Tue 01 Jul 2008 - 22:50:25 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 Tue 01 Jul 2008 - 23:31:30 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.

list of date sections of archive