Could you go ahead and supply a fully working example?
#Create a list of colors to be used with scale_manual
palette.l <- list()
palette.l[[1]] <- c('red', 'blue', 'green')
palette.l[[2]] <- c('pink', 'blue', 'yellow')
# Store each ggplot in a list object
plot.l <- list()
#Loop it
for(i in 1:2){
plot.l[[i]] <- qplot(mpg, wt, data = mtcars, colour = factor(cyl)) +
scale_colour_manual(values = palette.l[[i]])
}
In my session plot.l[1] will be painted with colors from palette.l[2].
#Out of a loop
#works plot 1
ggplot(data= mtcars, aes(x=wt, y=mpg, colour = factor(cyl))) +
geom_point()+
scale_colour_manual(values = palette.l[[1]])
#works plot 2
ggplot(data= mtcars, aes(x=wt, y=mpg, colour = factor(cyl))) +
geom_point()+
scale_colour_manual(values = palette.l[[2]])
for(i in 1:2){
plot.l[[i]] <- ggplot(data= mtcars, aes(x=wt, y=mpg, colour = factor(cyl))) +
geom_point()+
scale_colour_manual(values = palette.l[[i]])
}
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2