[R-Forge #5873] plot2.xts - addLines error
Closed this issue · 1 comments
Submitted by: Peter Carl
Assigned to: Nobody
R-Forge link
plot2_xts(CumReturns(R), theme=pccTheme, multi.panel=TRUE)
addLines(SMA(CumReturns(R[,1]), n=10), col='darkgray', on=1)
Error in text.default(NROW(xdata[xsubset]) + 1/3, grid_lines(xdata, xsubset), :
zero-length 'labels' specified
Here's the traceback:
10 text.default(NROW(xdata[xsubset]) + 1/3, grid_lines(xdata, xsubset),
noquote(format(grid_lines(xdata, xsubset), justify = 'right')),
col = theme$labels, offset = 0, pos = 4, cex = 0.9, xpd = TRUE)
9 text(NROW(xdata[xsubset]) + 1/3, grid_lines(xdata, xsubset),
noquote(format(grid_lines(xdata, xsubset), justify = 'right')),
col = theme$labels, offset = 0, pos = 4, cex = 0.9, xpd = TRUE)
8 eval(expr, envir, enclos)
7 eval(aob, env) at replot_xts.R#243
6 FUN(X[[13L]], ...)
5 lapply(x$Env$actions, function(aob) {
if (attr(aob, 'frame') > 0) {
x$set_frame(attr(aob, 'frame'), attr(aob, 'clip'))
env <- attr(aob, 'env')
if (is.list(env)) {
env <- unlist(lapply(env, function(x) eapply(x, eval)),
recursive = FALSE)
}
eval(aob, env)
}
}) at replot_xts.R#235
4 plot.replot_xts(x, ...)
3 plot(x, ...) at replot_xts.R#207
2 print.replot_xts()
1 print()
Despite the error, the line is drawn correctly.
Is there a better way to overlay a transformation of a line onto the line in a multi.panel series? Maybe I haven't discovered it yet...
pcc
Followups:
Date: 2014-08-14 20:50
Sender: Peter Carl
I now see that although the line is drawn correctly, there's no legend.
Unable to replicate this error. I am able to add lines to multi-panel plots.