XTS plot of intra-daily stock prices
Hi Costas,
Unfortunately, I think this isn't exactly a trivial thing to do: R
doesn't by default support broken axis plots (which I think is more or
less what you are looking for). I'm interested in helping you out with
this, but just to make sure I understand what you are looking for,
your data is something like
tm <- as.POSIXct(1342207451, origin = "1970-01-01")
x <- xts(rnorm(100), tm+ 100*c(0:49, 0:49 + 5e2))
plot(x)
and you want that long flat bit omitted?
Here's a cheap hack to work around if I understand the problem:
plot.by.day <- function(x, ...){
ti <- deparse(substitute(x))
x2 <- split(x, as.Date(index(x), tz = ""))
op <- par(no.readonly = TRUE)
par(mfrow = c(1, length(x2)), mar = c(5.1, 0, 4.1, 0), oma = c(0,
4.1, 1, 2.1))
for(x3 in x2) xts::plot.xts(as.xts(x3), yaxt = "n", main = "",
ylim = range(x), ...)
mtext(ti, outer = TRUE, cex = 2, line = -2)
}
It could use some more work though. (and I just wipped it up, so it
will probably break in all sorts of unpleasant ways) Lemme know how it
goes for you and I might start polishing it.
Best,
Michael
On Fri, Jul 13, 2012 at 1:50 PM, Costas Vorlow <costas.vorlow at gmail.com> wrote:
Hello, When I plot more than a day's xts time series data on a stock (intra-daily frequency) I get gaps during the non-trading hours. I placed some examples here: http://users.hol.gr/~laurarvc/Costas/R/ Can I homogenize the plots i.e., skip those gaps so I have more continuous plots of high frequency prices? I can't find something on the help page of the relevant plot command... Best regards, Costas -- +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ |c|o|s|t|a|s|@|v|o|r|l|o|w|.|o|r|g| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ [[alternative HTML version deleted]]
_______________________________________________ R-SIG-Finance at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance -- Subscriber-posting only. If you want to post, subscribe first. -- Also note that this is not the r-help list where general R questions should go.