[R] Giving vector of colors to line in plots
statmobile
statmobile at gmail.com
Mon Feb 7 07:15:42 CET 2011
Hey all,
I can't for the life of me figure out what I'm missing here. I'm trying
to change the color of the line in a time series type plot. I can
change the point colors and symbols no problem, but for some reason the
colors do not get passed to the lines, regardless of if I do type="b" or
type="l". The sample code I'm using is below.
Any help would be greatly appreciated.
Also, please CC me, as I only get daily summaries of the mailing list.
Thanks,
Brian
## Changing plot attributes through the plot
set.seed(33)
x <- rpois(7,lambda=7)
y <- rpois(7,lambda=5)
cols.x <- c(rep("black",2),rep("red",3),rep("black",2))
cols.y <- c(rep("blue",3),rep("yellow",2),rep("blue",2))
points.x <- c(rep("x",2),rep("O",3),rep("x",2))
points.y <- c(rep(8,3),rep(17,2),rep(8,2))
plot(x,col=cols.x,pch=points.x,type="b",ylim=c(0,15))
points(y,col=cols.y,pch=points.y,type="b")
More information about the R-help
mailing list