[R] using "plot" with time series object - "axes = FALSE" option does not appear to work

Clifford Long gnolffilc at gmail.com
Mon Jan 3 07:03:15 CET 2011


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"



More information about the R-help mailing list