Skip to content
Prev 44662 / 398506 Next

how to plot multi- lines on one diagram

On Sun, 2004-02-22 at 13:58, liu qin wrote:
See ?matplot

Example:

# create a 4 column matrix
data1 <- matrix(1:40, ncol = 4)
[,1] [,2] [,3] [,4]
 [1,]    1   11   21   31
 [2,]    2   12   22   32
 [3,]    3   13   23   33
 [4,]    4   14   24   34
 [5,]    5   15   25   35
 [6,]    6   16   26   36
 [7,]    7   17   27   37
 [8,]    8   18   28   38
 [9,]    9   19   29   39
[10,]   10   20   30   40

# Now plot the four columns as lines
matplot(data1, type = "l")

HTH,

Marc Schwartz