-1

I want to plot multiple geom_lines in ggplot2 in a for loop. I am able to plot lines but am facing problem in coloring them. can anyone suggest how to do this?

pp=ggplot(a,aes(x=a$Nucleotide_position),y=data[,1:(length(a)-1)])
for (i in 1:(length(a)-1))
{ 
    pp=pp+geom_line(aes(x,y),data=data.frame(x=a$Nucleotide_position,y=a[,i]))
}

print(pp)
ks1322
  • 33,961
  • 14
  • 109
  • 164
  • Insert in aes(x,y, color = factor(x)) or factor (y) it is not clear how ur data frame looks like. – yuliaUU Dec 21 '19 at 07:35
  • It's hard to help right now without much information. [See here](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) on making a reproducible example. And why is this tagged Linux? – camille Dec 21 '19 at 16:33

1 Answers1

0

Insert in aes(x,y, color = factor(x)) or factor (y) it is not clear how ur data frame looks like.

yuliaUU
  • 1,581
  • 2
  • 12
  • 33