From 4a525e975f278eef9312016b679c278d7a4328d2 Mon Sep 17 00:00:00 2001 From: Ethan Smith <24379655+ethanbsmith@users.noreply.github.com> Date: Sun, 3 Nov 2024 10:50:55 -0700 Subject: [PATCH] Fix handling of col, lty, lwd in multi.panel plots Commit 3086e140f126b67fd0fc877595c4f0730f7fe1f1 introduced a regression. The prior behavior allowed every data point in the series to have a different color, line type, and line width. Fixes #426. --- R/plot.R | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/R/plot.R b/R/plot.R index ab07ad8..0239fb1 100644 --- a/R/plot.R +++ b/R/plot.R @@ -362,15 +362,20 @@ plot.xts <- function(x, legend.loc=NULL, extend.xaxis=FALSE){ - # 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)) + if(is.numeric(multi.panel) || isTRUE(multi.panel)) { + # Only need to check pars in multipanel scenarios. The single panel + # scenarios supports colors for each data point in the series. + # 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 # size of 2 and plot 2 panels on each page