# Re: [R] Graph Order in xyplot

From: hippie dream <tonightsthenight_at_gmail.com>
Date: Tue, 01 Jul 2008 16:00:21 -0700 (PDT)

as.table =TRUE was exactly what I needed. Also thanks for the little aside.

Gabor Grothendieck wrote:

```>
> Here are some ways of rearranging panels:
>
> library(lattice)
> p <- xyplot(Sepal.Length ~ Sepal.Width | Species, iris)
> p
> p[c(2, 1, 3)]
>
> xyplot(Sepal.Length ~ Sepal.Width | Species, iris, as.table = TRUE)
>
>
> On Tue, Jul 1, 2008 at 6:20 PM, 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")
>>
>> 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)
>>
>> 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. Thanks.
>>
>> [[alternative HTML version deleted]]
>>
>> ______________________________________________
>> R-help_at_r-project.org mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> http://www.R-project.org/posting-guide.html
>> and provide commented, minimal, self-contained, reproducible code.
>>
```>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
>

```
```--
View this message in context: http://www.nabble.com/Graph-Order-in-xyplot-tp18226583p18227085.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help