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 8440415
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:17:34+00:00 2026-06-10T08:17:34+00:00

My goal is to construct a levelplot (from the lattice package) with 4 or

  • 0

My goal is to construct a levelplot (from the lattice package) with 4 or more individual plots sharing the same colorkey. While this appears to be relatively simple using functions, I haven’t been able to find a solution using data matrices. An example of a working levelplot with just one matrix:

d <- replicate(10,rnorm(10))
levelplot(d)

I have found partial solutions using print and split to show all 4 levelplots on the same screen, but these would require me to either turn off the colorkey, or show it on every plot. Neither solution is completely satisfactory.

If I use the layout-option in levelplot, like so:

levelplot(d, layout=c(2,2))

, I get the desired layout, with one large colorkey, main and xlab/ylab, but only one levelplot prints.

I have been trying to construct a formula that yields the desired result, but I’m afraid my understanding of data frames, arrays and matrices is not deep enough to do so. If anyone knows of a working solution, I would be very grateful. What I imagine is something along the line of (not working code):

d1 <- replicate(10,rnorm(10))
d2 <- replicate(10,rnorm(10))
d3 <- replicate(10,rnorm(10))
d4 <- replicate(10,rnorm(10))

d <- list(d1,d2,d3,d4)
di <- c(1,2,3,4)

levelplot(x ~ y | di, data = d, layout=c(2,2))

NB! Avoiding the matrices is not an option. Some of them are obtained from raw text files.

Thank you in advance,

-JP

  • 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-06-10T08:17:35+00:00Added an answer on June 10, 2026 at 8:17 am

    Using ggplot and reshape along with your list d:

    require(reshape)
    require(ggplot2)
    
    ggplot(melt(d), aes(x=X1, y=X2)) +
      facet_wrap(~ L1, ncol=2) +
      geom_tile(aes(fill=value)) +
      coord_equal()
    

    Which gives:

    enter image description here

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

Sidebar

Related Questions

I want to construct a query like this: SELECT * FROM t1 WHERE visible='yes'
Goal is to make a dialog that appears on menu_key pressed, but it keeps
Goal: Produce an Excel document with information from 3 associated models that is similar
I'm trying to achieve the following goal: Using this general singleton class: abstract class
This is proof of concept project - The goal is to create an application
My main goal is to construct a ListView which places groups of three radio
I'm trying to construct a Link. The resulting Link should look something like this:
This is the singleton pattern also named as the singleton class. Its goal is
I'm trying to construct a page layout that will look something like this: In
Goal : To send an email with a list of URLs generated from nodes.

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.