0

What I want to do is to make a single line plot and then when the Att value change to the other factor, then the line plot change the color. All in the same line plot. As an example I have the following data frame:

Att <- as.factor(rep(1:3,each = 10))
x <- rnorm(30)
df <- cbind(Att, x)

I´ve tried with this code:

plot(df[,2], typ = "l", col = Att)

but I didn´t have the result that I want it.

Any suggestions?

Víctor Cortés
  • 473
  • 4
  • 9
  • 1
    You can check [here](http://stackoverflow.com/questions/7744379/elegant-way-to-select-the-color-for-a-particular-segment-of-a-line-plot). Convert to data.frame and `ggplot(df1, aes(x=seq_len(nrow(df1)),y=x))+geom_line(aes(colour=Att))` – akrun Sep 29 '15 at 05:56
  • 1
    Thanks a lot for the information. – Víctor Cortés Oct 02 '15 at 18:41

0 Answers0