# Re: [R] Plotting rows (or columns) from a matrix in different graphs, not using "par"

From: Gabor Grothendieck <ggrothendieck_at_gmail.com>
Date: Wed 15 Jun 2005 - 08:04:26 EST

On 6/14/05, Camarda, Carlo Giovanni <Camarda@demogr.mpg.de> wrote:
> Dear R-users,
> I would like to ask whether it's possible (for sure it would be), to
> plot each rows (or columns) in different graphs and in the same figure
> region without using the function "par" and then struggling around with
> "axes" and labels etc.
> Luckily, I would always have "rows + columns = even number" and the same
> "ylim".
>
> The next one could be a sort of example on what I would like to avoid
> plotting the rows of the matrix "mat":
>
> ########### EXAMPLE ######################
> dat <- sort(runif(16, 1, 1000))
> mat <- matrix(dat, ncol=4, byrow = T)
> y <- seq(1950, 1953)
> par(mfrow=c(2,2))
> plot(y, mat[1,], ylim=c(1,1000), axes=F, xlab="", ylab="simul.")
> box()
> axis(side=2, tick=T, labels=T)
> axis(side=3, tick=T, labels=T)
> plot(y, mat[2,], ylim=c(1,1000), axes=F, xlab="", ylab="")
> box()
> axis(side=3, tick=T, labels=T)
> plot(y, mat[3,], ylim=c(1,1000), axes=F, xlab="years", ylab="simul.")
> box()
> axis(side=1, tick=T, labels=T)
> axis(side=2, tick=T, labels=T)
> plot(y, mat[4,], ylim=c(1,1000), axes=F, xlab="years", ylab="")
> box()
> axis(side=1, tick=T, labels=T)
> ########### END EXAMPLE ########################
>
> Naturally something more compact would be even nicer.
>

plot(ts(mat, start = 1950), nc = 2)

R-help@stat.math.ethz.ch mailing list