[R] Graph Order in xyplot
Gabor Grothendieck
ggrothendieck at gmail.com
Wed Jul 2 00:30:14 CEST 2008
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
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
More information about the R-help
mailing list