diff --git a/R/plot.R b/R/plot.R index 6a166b5..92303af 100644 --- a/R/plot.R +++ b/R/plot.R @@ -154,9 +154,10 @@ chart.lines <- function(x, if(is.null(col)) col <- xx$Env$theme$col - if(length(lty) < NCOL(x)) lty <- rep(lty, length.out = NCOL(x)) - if(length(lwd) < NCOL(x)) lwd <- rep(lwd, length.out = NCOL(x)) - if(length(col) < NCOL(x)) col <- rep(col, length.out = NCOL(x)) + # ensure pars have ncol(x) elements + lty <- rep(lty, length.out = NCOL(x)) + lwd <- rep(lwd, length.out = NCOL(x)) + col <- rep(col, length.out = NCOL(x)) for(i in NCOL(x):1) { # x-coordinates for this column @@ -247,10 +248,14 @@ plot.xts <- function(x, legend.loc=NULL, extend.xaxis=FALSE){ - # recycle inputs - if(length(lty) < ncol(x)) lty <- rep(lty, length.out = ncol(x)) - if(length(lwd) < ncol(x)) lwd <- rep(lwd, length.out = ncol(x)) - if(length(col) < ncol(x)) col <- rep(col, length.out = ncol(x)) + # check for colorset or col argument + if(hasArg("colorset")) { + col <- eval.parent(plot.call$colorset) + } + # ensure pars have ncol(x) elements + col <- rep(col, length.out = NCOL(x)) + lty <- rep(lty, length.out = NCOL(x)) + lwd <- rep(lwd, length.out = NCOL(x)) # Small multiples with multiple pages behavior occurs when multi.panel is # an integer. (i.e. multi.panel=2 means to iterate over the data in a step @@ -360,11 +365,6 @@ plot.xts <- function(x, # lines of margin to the 4 sides of the plot: c(bottom, left, top, right) cs$Env$mar <- if (hasArg("mar")) eval.parent(plot.call$mar) else c(3,2,0,2) - # check for colorset or col argument - # if col has a length of 1, replicate to NCOL(x) so we can keep it simple - # and color each line by its index in col - if(hasArg("colorset")) col <- eval.parent(plot.call$colorset) - if(length(col) < ncol(x)) col <- rep(col, length.out = ncol(x)) cs$Env$format.labels <- format.labels cs$Env$yaxis.ticks <- yaxis.ticks cs$Env$major.ticks <- if (isTRUE(major.ticks)) "auto" else major.ticks @@ -373,11 +373,6 @@ plot.xts <- function(x, cs$Env$grid.ticks.lwd <- grid.ticks.lwd cs$Env$grid.ticks.lty <- grid.ticks.lty cs$Env$type <- type - - # if lty or lwd has a length of 1, replicate to NCOL(x) so we can keep it - # simple and draw each line with attributes by index - if(length(lty) < ncol(x)) lty <- rep(lty, length.out = ncol(x)) - if(length(lwd) < ncol(x)) lwd <- rep(lwd, length.out = ncol(x)) cs$Env$lty <- lty cs$Env$lwd <- lwd