SCM

Forum: help

Monitor Forum | Start New Thread Start New Thread
RE: multiple series color through panel= [ Reply ]
By: Achim Zeileis on 2013-08-02 20:21
[forum:39770]
Brian, the problem is that your panel function sets the 'col' argument by itself rather than using the information passed through from the plot function (via the '...' argument). To get a reproducible example:

## generate data
set.seed(1)
z <- zoo(matrix(rnorm(180), ncol = 18))

## colors and screens
cl <- rep(c("skyblue", "skyblue4"), each = 9)
sc <- rep(1:9, 2)

## without the abline
plot(z, screens = sc, col = cl)

## with abline
mypanel <- function(x, y, ...) {
lines(x, y, ...)
abline(h = 0, col = "red", lty = 2)
}
plot(z, screens = sc, col = cl, panel = mypanel)

I hope this solves your problem.

Best,
Z

multiple series color through panel= [ Reply ]
By: Brian Davidhizar on 2013-08-02 15:18
[forum:39769]
Hello:

Trying to pass to panel= in plot.zoo() such that in each panel the color of lines plotted alternates. The below is currently failing. Zoo object being passed has 18 columns. Columns 1:9 are plotted one in each of the 9 panels and columns 10:18 are then plotted in each of the same 9 panels. If panel= is omitted, I get the desired results, but must do without the desired abline!

abline.zoo <- function(x, y, ...) {
lines(x, y,col=c("skyblue",skyblue4");
abline(h=0,col="red",lty=3);
}

dev.new()
plot(smUSeqExcessReturns3yr5yrNet.zoo.merge,
screens=rep(c(1:9),2),
panel=abline.zoo,
col=c(rep(c("skyblue"),9),rep(c("skyblue4"),9)),
ylim=c(-5,10),xlab="Date",cex.main=.85,
main="Light Color = Rolling 3yr -- Dark Color = Rolling 5yr \n "
)

Any feedback would be greatly appreciated.

Thanks,
Brian Davidhizar
T. Rowe Price

Thanks to:
Vienna University of Economics and Business Powered By FusionForge