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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T23:50:15+00:00 2026-05-25T23:50:15+00:00

The update method of trellis plots allows one to modify a lattice plot after

  • 0

The update method of trellis plots allows one to modify a lattice plot after the initial call. But the update behaviour is more like replace than append. This differs from the ggplot2 idiom where each new layer is additive to what exists already. Is it possible to get this additive behaviour using lattice?

An example:

LL <- barchart(yield ~ variety | site, data = barley,
        groups = year, stack = TRUE,
        between=list(y=0.5),
        scales = list(x = list(rot = 90)))
print(LL)

enter image description here

Now I want to add panel.text to the existing plot. Using update in the following way doesn’t work:

update(LL, panel=function(...){
           args <- list(...); panel.text(args$x, args$y+2, round(args$y, 0))
         })

enter image description here

I know that I can use update by specifying all of the layers in the panel function:

update(LL, panel=function(...){
           args <- list(...)
           panel.barchart(...)
           panel.text(args$x, args$y+2, round(args$y, 0))
         })

This will work, but requires that I know what is already in the lattice plot – or that I refactor my code quite substantially.

Question: Is there a way of adding to the existing panel in update.trellis?

  • 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-25T23:50:15+00:00Added an answer on May 25, 2026 at 11:50 pm

    See layer from the latticeExtra package.

    library(lattice)
    library(latticeExtra)
    LL <- barchart(yield ~ variety | site, data = barley,
            groups = year, stack = TRUE,
            between=list(y=0.5),
            scales = list(x = list(rot = 90)))
    LL + layer(panel.text(x, y, round(y, 0), data=barley))
    

    result of code

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

Sidebar

Related Questions

Say I have a controller with an Index Method and a Update Method. After
Update: Replaced the destructor example with a straight up method call example. Hi, If
I have an update method in my users controller that I call from a
I have two threads. One invokes the update method of a class that modifies
The update method is saving the data but the redirect is failing to render
I'm just trying to schedule an update method once in ccTouchesMoved, but when I
Is it ok to call the SQLiteDatabase update method in the insert() overridden method
My MySqlConnection class implements IDatabaseConnection interface. In update method, I want to call connect()
i have created a 3tier application.. where i want to call the update method
I've had problems with the update method in subsonic, so instead of using: a.Update()

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.