1

Suppose I have a matrix with n columns and m rows. In my case I have a setup depending on a parameter which can take n different values. For each of these values I do some calculation, the m elements in the rows. Now I would like to plot each column against a vector (timestep), which is of course of length m. How do I do this? It should be something like plot(timestep,i-th column)? Thanks in advance!

cheers

math

math
  • 1,868
  • 4
  • 26
  • 60

1 Answers1

1

Since you didn't provide any reproducible example I supposed you need something like this:

set.seed(001) # generating som data
Matrix <- matrix(rnorm(40,100,5), 10)
Vector <- rnorm(10, 200, 30)
par(mfrow=c(2,2))
for(i in 1:ncol(Matrix)){
  plot(Matrix[,i] ~ Vector, pch=16, cex=.65, col=i,
       main=paste('Column', i, 'of Matrix agaisnt Vector'))
}
par(mfrow=c(1,1))

Which produces...

enter image description here

Community
  • 1
  • 1
Jilber Urbina
  • 58,147
  • 10
  • 114
  • 138