Clifford Long
2011-Jan-03 06:03 UTC
[R] using "plot" with time series object - "axes = FALSE" option does not appear to work
Dear R-help, I am attempting to plot data using standard R plot utilities. The data was retrieved from FRED (St. Louis Federal Reserve) using the package quantmod. My question is NOT about quantmod. While I retrieve data using quantmod, I am not using its charting utility. I have been having success using the standard R "plot" utilities to this point with this type of data. Eventually I want to put two series on the same plot but with the y-axis for one series on the right side, and also inverted (min at the top, max at the bottom). I believe that I see how to do this by using par(new = TRUE) with a second plot statement with "axes = FALSE", followed by the command "axis(side = 4, ylim = c(max(seriesname), min(seriesname))". Here is what I believe should be a smaller reproducible example of my issue: #----------------------------------------------------------------- library(quantmod) getSymbols('PCECTPI', src='FRED') is.xts(PCECTPI) # check the type of object - response is 'TRUE' plot(PCECTPI) # This works fine. plot(PCECTPI, axes = FALSE) # This works in that it gives me a plot, but I get the axes regardless of the use of "axes = FALSE". #----------------------------------------------------------------- I did find that using par(yaxt = "n") seems to work to suppress the y-axis. But it seems to me that the "axes = FALSE" command should also work, and I believe that it would be easier to use in the larger context of my goal. I have spent time with the R help pages and Nabble searches of the R help archives but I still seem to be missing something. Does the "axes = FALSE" option not work when using plot with this type of data object? Is there some other fundamental thing that I have overlooked? Or should this work? My apologies if the answer is obvious and I've just missed it. Thank you in advance for any help that can be provided. Cliff Long gnolffilc at gmail.com #################################################################### My system: HP Pavilion Windows 7 The computer/OS is 64-bit. I am running the precompiled 32-bit version of R (per sessionInfo). Thus far, everything seems to have been working as expected.> sessionInfo()R version 2.12.1 (2010-12-16) Platform: i386-pc-mingw32/i386 (32-bit) locale: [1] LC_COLLATE=English_United States.1252 [2] LC_CTYPE=English_United States.1252 [3] LC_MONETARY=English_United States.1252 [4] LC_NUMERIC=C [5] LC_TIME=English_United States.1252 attached base packages: [1] stats graphics grDevices utils datasets methods base other attached packages: [1] quantmod_0.3-15 TTR_0.20-2 xts_0.7-5 zoo_1.6-4 [5] Defaults_1.1-1 loaded via a namespace (and not attached): [1] grid_2.12.1 lattice_0.19-13 tools_2.12.1> Sys.getlocale()[1] "LC_COLLATE=English_United States.1252;LC_CTYPE=English_United States.1252;LC_MONETARY=English_United States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252"
Mike Marchywka
2011-Jan-03 11:32 UTC
[R] using "plot" with time series object - "/hijack thread for quetion re R data capture
> Date: Mon, 3 Jan 2011 00:03:15 -0600 > From: gnolffilc at gmail.com > To: r-help at r-project.org > Subject: [R] using "plot" with time series object - "axes = FALSE" option does not appear to work > > Dear R-help, > > I am attempting to plot data using standard R plot utilities. The > data was retrieved from FRED (St. Louis Federal Reserve) using the > package quantmod. My question is NOT about quantmod. While I > retrieve data using quantmod, I am not using its charting utility. I[...]> > Here is what I believe should be a smaller reproducible example of my issue: > > #----------------------------------------------------------------- > > library(quantmod) > > getSymbols('PCECTPI', src='FRED') > is.xts(PCECTPI) # check the type of object - response is 'TRUE' > > plot(PCECTPI) # This works fine. >I just tried the example and got a graph of something, presumably using data downloaded from the data provider FRED. I have a lot of bash scripts to download data from various FRB web pages but I seem to recall these are based on scraping html and maybe their ftp site ( I'm too lazy to look but I do remember they had csv data files for download). Often with sites like this, there is no API or even stable web pages from which to scrape data. Generally how stable are the R data download things when no agreement with data provider is in place? I'm impressed that someone is willing to maintain such a helpful facility as this is the most annoying kinds of stuff to write but also note that sometimes agencies do solicit public input on related topics and it may be helpful for R users to response and comment on the importance of computer readable data.
Victor F Seabra
2011-Jan-03 13:09 UTC
[R] using "plot" with time series object - "axes = FALSE" option does not appear to work
I guess you should specify x and y variables: plot(x=PCECTPI$var1, y=PCECTPI$var2, axes = FALSE)
Clifford Long
2011-Jan-03 13:31 UTC
[R] using "plot" with time series object - "axes = FALSE" option does not appear to work
Dear R-help, I am told by Professor Ripley that my question (quote) wastes the time of (and has insulted on-list) the R developers by falsely claiming there are problems with their code. I am writing, as he instructed, to publicly apologize to the R developers for any slight that my question might have generated. When posing my question, I genuinely thought that by invoking "plot" that it was a Base R graphics package that I was using, and not that offered by Mr. Ryan. As I am told that I owe an apology, I would like to do as I was instructed and publicly apologize on the list to the R developers, but not for any malicious intent, but rather for my lack of expertise and any unintentional insult that resulted. (My apologies also to Mr. Ryan for my ignorance.) Signed "bruised, but maybe a little less ignorant about R". Cliff Long gnolffilc at gmail.com On Mon, Jan 3, 2011 at 12:03 AM, Clifford Long <gnolffilc at gmail.com> wrote:> Dear R-help, > > I am attempting to plot data using standard R plot utilities. ?The > data was retrieved from FRED (St. Louis Federal Reserve) using the > package quantmod. ?My question is NOT about quantmod. ?While I > retrieve data using quantmod, I am not using its charting utility. ?I > have been having success using the standard R "plot" utilities to this > point with this type of data. > > Eventually I want to put two series on the same plot but with the > y-axis for one series on the right side, and also inverted (min at the > top, max at the bottom). ?I believe that I see how to do this by using > par(new = TRUE) with a second plot statement with "axes = FALSE", > followed by the command "axis(side = 4, ylim = c(max(seriesname), > min(seriesname))". > > Here is what I believe should be a smaller reproducible example of my issue: > > #----------------------------------------------------------------- > > library(quantmod) > > getSymbols('PCECTPI', src='FRED') > is.xts(PCECTPI) ? ? ?# check the type of object - response is 'TRUE' > > plot(PCECTPI) ?# This works fine. > > plot(PCECTPI, axes = FALSE) ?# This works in that it gives me a plot, > but I get the axes regardless of the use of "axes = FALSE". > > #----------------------------------------------------------------- > > I did find that using par(yaxt = "n") seems to work to suppress the > y-axis. ?But it seems to me that the "axes = FALSE" command should > also work, and I believe that it would be easier to use in the larger > context of my goal. > > > I have spent time with the R help pages and Nabble searches of the R > help archives but I still seem to be missing something. > > Does the "axes = FALSE" option not work when using plot with this type > of data object? > Is there some other fundamental thing that I have overlooked? > Or should this work? > > My apologies if the answer is obvious and I've just missed it. ?Thank > you in advance for any help that can be provided. > > Cliff Long > gnolffilc at gmail.com > > > #################################################################### > > My system: > HP Pavilion > Windows 7 > The computer/OS is 64-bit. ?I am running the precompiled 32-bit > version of R (per sessionInfo). > Thus far, everything seems to have been working as expected. > > >> sessionInfo() > R version 2.12.1 (2010-12-16) > Platform: i386-pc-mingw32/i386 (32-bit) > > locale: > [1] LC_COLLATE=English_United States.1252 > [2] LC_CTYPE=English_United States.1252 > [3] LC_MONETARY=English_United States.1252 > [4] LC_NUMERIC=C > [5] LC_TIME=English_United States.1252 > > attached base packages: > [1] stats ? ? graphics ?grDevices utils ? ? datasets ?methods ? base > > other attached packages: > [1] quantmod_0.3-15 TTR_0.20-2 ? ? ?xts_0.7-5 ? ? ? zoo_1.6-4 > [5] Defaults_1.1-1 > > loaded via a namespace (and not attached): > [1] grid_2.12.1 ? ? lattice_0.19-13 tools_2.12.1 > > >> Sys.getlocale() > [1] "LC_COLLATE=English_United States.1252;LC_CTYPE=English_United > States.1252;LC_MONETARY=English_United > States.1252;LC_NUMERIC=C;LC_TIME=English_United States.1252" >
Ben Bolker
2011-Jan-03 15:10 UTC
[R] using " plot" with time series object - " axes = FALSE" option does not appear to work
Clifford Long <gnolffilc <at> gmail.com> writes:> > Dear R-help, > > I am told by Professor Ripley that my question (quote) wastes the time > of (and has insulted on-list) the R developers by falsely claiming > there are problems with their code. I am writing, as he instructed, > to publicly apologize to the R developers for any slight that my > question might have generated. > > When posing my question, I genuinely thought that by invoking "plot" > that it was a Base R graphics package that I was using, and not that > offered by Mr. Ryan. > > As I am told that I owe an apology, I would like to do as I was > instructed and publicly apologize on the list to the R developers, but > not for any malicious intent, but rather for my lack of expertise and > any unintentional insult that resulted. (My apologies also to Mr. > Ryan for my ignorance.) >Your post did not look insulting to me, just mildly (and understandably) misinformed. It looks to me like this is a bug in plot.xts, which has the code dots <- list(...) if ("axes" %in% names(dots)) { if (!dots$axes) axes <- FALSE } else axes <- TRUE This would make sense if axes were *not* in the explicit list of arguments to the function, and the default was supposed to be TRUE. Because axes *is* in the explicit list of arguments, this overrides it. I would contact the maintainer [maintainer("xts")] and ask if this is a bug. cheers Ben Bolker