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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:48:19+00:00 2026-05-27T18:48:19+00:00

In the following recorded plot, I cannot find the instruction that constructs the layout

  • 0

In the following recorded plot, I cannot find the instruction that constructs the layout and sets the par() settings before the first plot.new call()

library( PerformanceAnalytics )
data( managers )

# write the plot to the open device
suppressWarnings(charts.RollingRegression(managers[, 1:6], managers[, 8, drop=FALSE], Rf = .04/12, colorset = rich6equal, legend.loc="topleft"))

# record = investigate the primitive calls.  notice no par() nor layout() before the first call to plot.new()
recorded = recordPlot()
lapply(recorded[[1]], "[[", 1 )

# as a result, the following creates one plot per page, not 3 on the same page:
lapply( recorded[[ 1 ]] , function( x ) { do.call( x[[ 1 ]] , as.list( x[[ 2 ]] ) ) } )

Perhaps this is encoded in recorded[[ 2 ]] which looks like some kind of encoded raw data? If so, how could I grab the insructions prior to the first plot.new() from the raw data?

Edit
Warning: dirty hack.
If you want to encode the initial state in the instruction list, here’s how:

tryCatch( dev.off() , error = function( e ) {} )
plot.new()
par( new = TRUE )
originalLayoutFunction = graphics:::layout
graphicsEnvironment = as.environment( "package:graphics" )
newLayoutFunction = function( ... )
{
    originalLayoutFunction( ... )
    par( mfg = c( 1 , 1 ) )
}

unlockBinding( "layout" , env = graphicsEnvironment )
assign( "layout" , newLayoutFunction , envir = graphicsEnvironment )
lockBinding( "layout" , env = graphicsEnvironment )

tryCatch( YOUR_PLOT_CALL_HERE , finally = 
                                { 
                                    unlockBinding( "layout" , env = graphicsEnvironment )
                                    assign( "layout" , originalLayoutFunction , env = graphicsEnvironment )
                                    lockBinding( "layout" , env = graphicsEnvironment )                                    
                                } )
recordedPlot = recordPlot()
dev.off()
  • 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-27T18:48:19+00:00Added an answer on May 27, 2026 at 6:48 pm

    You’re probably right about what’s in recorded[[2]]. My suspicion is that it contains the SEXP which “nicely hides the internals” referenced in this comment from the R sources:

    /****************************************************************
     * GEcreateSnapshot
     ****************************************************************
     */
    
    /* Create a recording of the current display,
     * including enough information from each registered
     * graphics system to be able to recreate the display
     * The structure created is an SEXP which nicely hides the
     * internals, because noone should be looking in there anyway
     * The product of this call can be stored, but should only
     * be used in a call to GEplaySnapshot.
     */
    

    A bit further down in the same file ($SRC_HOME/src/main/engine.c) is another possibly illuminating passage.

    Like the comment above (and like the recordPlot help file), it too comes with a strongish admonition not to try mucking around with the objects stored by recordPlot(). “Here be dragons”, they all say, and it looks like you are starting to meet them that were warned about 😉

    /****************************************************************
     * GEplaySnapshot
     ****************************************************************
     */
    
    /* Recreate a saved display using the information in a structure
     * created by GEcreateSnapshot.
     *
     * The graphics engine assumes that it is getting a snapshot
     * that was created in THE CURRENT R SESSION
     * (Thus, it can assume that registered graphics systems are
     *  in the same order as they were when the snapshot was
     *  created -- in patricular, state information will be sent
     *  to the appropriate graphics system.)
     * [With only two systems and base registered on each device at
     * creation, that has to be true: and grid does not save any state.]
     *
     *  It also assumes that the system that created the snapshot is
     *  still loaded (e.g. the grid namespace has not been unloaded).
     *
     * It is possible to save a snapshot to an R variable
     * (and therefore save and reload it between sessions and
     *  even possibly into a different R version),
     * BUT this is strongly discouraged
     * (in the documentation for recordPlot() and replayPlot()
     *  and in the documentation for the Rgui interface on Windows)
     */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Following up from this question: How can I unlock a file that is locked
I'm looking for a job queue that has the following features: Can specify a
I have the following problem: in a database table are Sales recorded. One of
What is the vb.net or c# equivalent of the following javascript? this.browserTime.value = Math.floor((new
I'm writing a program that requires the following kernel launch: dim3 blocks(16,16,16); //grid dimensions
Following is the Google Analytics code added just before close of /head in html
I have the following piece of code. I've recorded the output as well: function
I'm following this tutorial: http://www.javascripttoolbox.com/jquery/ And I'm trying to get table rows that are
I want to develop a tool that does the following things. take in a
I have a client application that should be able to handle the following: 1)

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.