I am trying to use scale_fill_manual to assign corresponding colors to factors across many plots in a nested for loop. However, the resulting plots end up all being black.
My overall loop is as follows:
for(i in seq(from=0, to=100, by=10)){
for{j in seq(from=0, to=100, by=10)){
print(ggplot(aes(x , y), data = df)+
geom_point(inherit.aes = FALSE,data = subset(df,factor_x==i&factor_y==j), aes(x, y, size=point,color=Group))+
theme_bw()}}
I am trying to assign each factor in "Group" its own color that plots consistently. I've tried using:
col<-colorRampPalette(brewer.pal(9,"Set1"))(16)
Then I assigned each color to a specific factor in "Group."
However, when using scale manual in the nested loop there is no color at all for the factors.
for(i in seq(from=0, to=100, by=10)){
for{j in seq(from=0, to=100, by=10)){
print(ggplot(aes(x , y), data = df)+
geom_point(inherit.aes = FALSE,data = subset(df,factor_x==i&factor_y==j), aes(x, y, size=point))+
theme_bw()+scale_fill_manual(values=col)}}
How can I integrate a color scheme for the categorical values in "Group" across the many plots generated in the loop?