Thursday 15 January 2015

r - Graph many superimposed lines -


I have a matrix mlinerror where each column is a time series starting from row 1 And ends in line 5.

I want to create a graph where there are several superimposed lines which are alpha mixed, preferably in which each row has a different color.

Here's my code:

  plt <- ggplot (Df) (in i: 1:99) {plt  plt & lt; - plt + geom_line (aes (x = 1: 5, y = mlinerror [] I [[I,]), alpha = 0.1)  manually (it should be 99 times) for each column and it underlines all the lines, but this composite does not work for my loop method . 

What should I do to create a multi-line graph?

You can do this more easily if you format your data for a long time. Here's an example with fake data. Is a time variable set by creating duplicate data with Library column (Rehep 2) # 100 times series column. Seed (30) data = data. Frames (time = 1: 5, repeat (

100, cumsum (rnorm (5)) # Melted dat.m = melted in long form (dat, id.var = "time") # In a different color ggplot, with each individual time series, Lot (data. M, AES (time, value, color = variable, group = variable)) + GOM_LINE (alpha = 0.2, show_guide = FALSE)


No comments:

Post a Comment