Skip to content

Commit

Permalink
handle color vector recycling
Browse files Browse the repository at this point in the history
- We need to be aware of the length of the color vector that is
  passed in the case of type="h". If the length of the vector is
  less than the number of elements in x, then R will recycle the
  colors. This is not the behavior we want.
- To fix this, I added a simple check of the length of the color
  vector and number of observations of x. If the color vector has
  fewer elements than the number of observations, then we only use
  the first element from the color vector.

see #224
  • Loading branch information
rossb34 committed Feb 28, 2018
1 parent 3d36a9c commit d5bd5cd
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions R/plot.R
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ chart.lines <- function(x,
} else {
colors <- if (is.null(col)) 1 else col
}
if (length(colors) < nrow(x[,1]))
colors <- colors[1]
lines(xx$Env$xycoords$x,x[,1],lwd=2,col=colors,lend=lend,lty=1,type="h",...)
},
p=, l=, b=, c=, o=, s=, S=, n={
Expand Down

0 comments on commit d5bd5cd

Please sign in to comment.