[R] how to plot multi- lines on one diagram
Marc Schwartz
MSchwartz at medanalytics.com
Sun Feb 22 21:25:50 CET 2004
On Sun, 2004-02-22 at 13:58, liu qin wrote:
> Hello there:
>
> I got a matrix as data1, I do need to plot each column
> and illustrate them as 4 lines on the same screen.
>
> Would anybody help me out please?
>
> > data1
> [,1] [,2] [,3] [,4]
> [1,] 94.35 60.89 33.12 0.1001
> [2,] 94.17 60.53 32.76 0.1003
> [3,] 94.35 61.80 34.74 0.0980
> [4,] 95.45 65.99 38.74 0.0910
> [5,] 95.82 69.44 38.38 0.0859
> [6,] 95.64 68.72 42.19 0.0903
> [7,] 94.35 69.28 43.11 0.2931
> [8,] 94.19 68.73 43.27 0.0980
> [9,] 93.82 65.81 38.36 0.1357
> [10,] 92.90 63.81 39.28 0.1353
>
> Thank you very much indeed,
>
> Qin Liu
See ?matplot
Example:
# create a 4 column matrix
data1 <- matrix(1:40, ncol = 4)
> data1
[,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
More information about the R-help
mailing list