Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7631253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T06:18:27+00:00 2026-05-31T06:18:27+00:00

I am trying to get a multi-page two-dimensional lattice panel plot to have the

  • 0

I am trying to get a multi-page two-dimensional lattice panel plot to have the same conditioning layout on multiple pages. The vertical arrangement should be

CCC
BBB
AAA

on each page. I know how to do this manually, but the code is ugly, especially if the last page is not completely filled.

In a 2010 SO thread, I read that this was “on the list” for ggplot2.

library(lattice)
d = expand.grid(f1 = as.factor(letters[1:10]),
            f2 = as.factor(LETTERS[1:3]),
            x  = 0:10)
d$y = rnorm(nrow(d))
xyplot(y~x|f1+f2,data=d,cex=0.5,pch=16,layout=c(5,3,2))

Note that all A are on the first page, followed by B, followed by B and C on the last page.

Edited following Gabor’s idea

library(lattice)
library(latticeExtra)

# Note: changed so that it does not fill the three pages
d <- expand.grid(f1 = as.factor(letters[1:8]),
            f2 = as.factor(LETTERS[1:3]),
            x  = 0:10)
d$y <- rnorm(nrow(d))
page <- factor((as.numeric(d$f1) - 1) %/% 5 + 1)
# The second (=last) page has different panel sizes
# Using aspect does not help
for(pg in levels(page)) {
  p <- xyplot(y ~ x|f1+f2, data = d[pg == page, ], cex = .5, pch = 16,
          layout = c(5, 3))
  print(useOuterStrips(p))
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T06:18:28+00:00Added an answer on May 31, 2026 at 6:18 am

    The placement of the panels can be achieved by writing a new packet.panel function that automatically draws the panels in the desired places.

    packet.panel.bycolumn <- function (layout, condlevels, page, row, column, skip) {
      dims <- sapply(condlevels, length)
      if(layout[2] != dims[2]) {
        stop("rows in layout must be equal to rows of second conditioning variable")
      }
      panels.per.row <- layout[1]
      panels.per.column <- layout[2]
      total.columns <- dims[1]
      panels.needed <- total.columns * panels.per.column
      panels.per.page <- layout[1] * layout[2]
      pages.needed <- ceiling(panels.needed / panels.per.page)
      empty.columns <- (panels.per.row - total.columns) %% panels.per.row
      panel.matrix <- rbind(matrix(1:panels.needed,ncol=panels.per.column),
                            matrix(NA, nrow=empty.columns, ncol=panels.per.column))
      panel.order <- as.vector(aperm(array(panel.matrix,
                                           dim=c(panels.per.row, pages.needed, panels.per.column)),
                                     c(1,3,2)))
      packet.order <- do.call(expand.grid, condlevels)[panel.order,]
      panel.number <- 1 + (page - 1) * panels.per.page + (row - 1) * panels.per.row + (column - 1)
      out <- as.numeric(packet.order[panel.number, ])
      if (any(is.na(out))) out <- NULL
      out
    }
    

    useOuterStrips will change the layout, but it can be changed back afterwards. The desired result can be achieved like this:

    p <- xyplot(y~x|f1+f2, data=d, cex=0.5, pch=16)
    p <- useOuterStrips(p)
    p <- update(p, layout=c(5,3))
    plot(p, packet.panel=packet.panel.bycolumn)
    

    enter image description here

    enter image description here

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

im trying to get multi texturing working and have so far got miltiple textures
I have a multi page form that I am trying to implement on my
i'm trying to get multi tenancy working in my app - using nhibernate integration
I am trying to parse a multi line string and get the rest of
I'm trying to make my C# application multi threaded because sometimes, I get an
Trying to get comfortable with jQuery and I have encountered some sample code that
I am trying to do a multi column filter as shown in this page
I'm currently trying to get comfortable with multi tier applications (Server / Client Architecture).
Hi fellow android developers, I'm trying to implement a multi-pane layout as described here
I'm trying to get my head around another issue i'm facing with my multi-tenant

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.