Kaja
Kaja

Reputation: 3057

drawing a scatter plot from two matrices

I would like to draw a scatter plot from two matrices:

the first matix contains my X-values on the diagram and has only one column.

   [,1]
[1,]  3
[2,]  5
[3,]  8
...   ...

Matrix B has n columns and they are my Y-Values in the diagram:

 [,1] [,2] [,3] ...
[1,]  80   85   25  ...
[2,]  42   35   57  ...
[3,]  81   52   39  ...
...  ... 

first row in Matrix b belongs to first row in matrix a.

I want to draw the scatter plot from this two matrices, for example for the value 3 on the X-axis I want to have points on the 80,85,25,.. Y-axis

How can I do this job?

Upvotes: 3

Views: 1681

Answers (1)

IRTFM
IRTFM

Reputation: 263342

To expand on Roland's comment:

matplot(a, b, type="p")   # "p" is the default but I put it in to highlight the possibility of using "l" or "b"

.... does exactly what you asked for: column of X versus columns of Y.

Upvotes: 4

Related Questions