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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:25:48+00:00 2026-05-26T14:25:48+00:00

After a call to the zooom function (which allows the user to interactively change

  • 0

After a call to the zooom function (which allows the user to interactively change the zoom of the chart by clicking on the leftmost and rightmost bounds for the zoom), is it possible to get the resulting subset displayed?

The reasons I want this:

  1. To set an appropriate yrange for my chart based on the custom TAs that I’ve added that would otherwise not be visible, because the automatic yrange is based only the timeseries passed to the original call to chartSeries
  2. To implement functions to pan the chart left and right

Workarounds for these 2 goals that don’t involve getting the current subset would also be helpful. Currently the only option I can think of is to avoid the use of the interactive zooom function and just use chartZoom.

  • 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-26T14:25:48+00:00Added an answer on May 26, 2026 at 2:25 pm

    The first thing to know is why zoomChart() returns the values you want, but zooom() doesn’t.

    zoomChart() does because it calls the function reChart(), which ends with the line invisible(chob). (chob is the name of the object you’re after.)

    zooom() doesn’t do this. It calls zoomChart(), but it doesn’t arrange to pass chob out of the environment within which zoomChart() is being evaluated. You can do that, though, by creating a modified version of zooom()

    I did this by first dumping zooom to a file and then creating an edited function called zooom2:

    require(quantmod)
    dump("zooom", file="zooom2.R")
    

    The three edits I made were:

    1. Replace calls to get.chob() with calls to quantmod:::get.chob(). This is needed because, unlike zooom, zooom2 does not have namespace:quantmod as its enclosing environment.

    2. Assign the output of zoomChart() to the object chob.

    3. Return chob to the calling environment by ending the function with invisible(chob).

    Here’s the modified function:

    zooom2 <-
    function (n = 1, eps = 2) 
    {
    for (i in 1:n) {
        cat("select left and right extremes by clicking the chart\n")
        points <- locator(2)
        if (abs(diff(points$x)) < eps) {
        zoomChart()
        }
        else {
        usr <- par("usr")
        xdata <- quantmod:::get.chob()[[2]]@xdata
        xsubset <- quantmod:::get.chob()[[2]]@xsubset
        sq <- floor(seq(usr[1], usr[2], 1))
        st <- which(floor(points$x[1]) == sq)/length(sq) * 
            NROW(xdata[xsubset])
        en <- which(floor(points$x[2]) == sq)/length(sq) * 
            NROW(xdata[xsubset])
        sorted <- sort(c(st, en))
        st <- sorted[1]
        en <- sorted[2] * 1.05
        chob <- zoomChart(paste(index(xdata[xsubset])[max(1, floor(st), 
            na.rm = TRUE)], index(xdata[xsubset])[min(ceiling(en), 
            NROW(xdata[xsubset]), na.rm = TRUE)], sep = "::"))
        }
    }
    cat("done\n")
    invisible(chob)
    
    }
    

    You can source or paste the function back into your R session, and then use it like this (for example):

      data(sample_matrix)
      chartSeries(sample_matrix)
      d <- zooom2()
      # Click to interactively zoom in
    
      # extract the data visible in the selected region
      d_sub <- d@xdata[d@xsubset,]
      head(d_sub)
    #                Open     High      Low    Close
    # 2007-03-28 48.33090 48.53595 48.33090 48.53595
    # 2007-03-29 48.59236 48.69988 48.57432 48.69988
    # 2007-03-30 48.74562 49.00218 48.74562 48.93546
    # 2007-03-31 48.95616 49.09728 48.95616 48.97490
    # 2007-04-01 48.94407 48.97816 48.80962 48.87032
    # 2007-04-02 48.90488 49.08400 48.90488 49.06316
    

    If this is something that’s useful to you, you might want to add it to the quantmod sources, and recompile your own version of the package.

    Hope this helps.

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

Sidebar

Related Questions

I've dug the manual and tried extensivelly to drop the extra function(){...} call after
In Delphi, why does the Assigned() function still return True after I call the
how can i disable live('click', function...) method and then after ajax call (depending on
I'm trying to call a function after I load some XML into Actionscript, and
After I call getpwuid(uid) , I have a reference to a pointer. Should I
I am calling a SQL proc that has 3 OUTPUT params. After the call
After my system call has returned because it was interrupted by a signal, is
I'm getting a segmentation fault the first time I call malloc() after I protect
I use glBindTexture() to bind a previously created texture. After the glBindTexture() call I
After reading the mkdir(2) man page for the Unix system call with that name,

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.