[R] Multiple plots with single box
    Giovanni Petris 
    GPetris at uark.edu
       
    Wed Dec 19 00:21:42 CET 2007
    
    
  
Hello,
I am trying to display some harmonic functions in a plot. The kind of
display I have in mind is like the one that cn be obtained by a call
to plot.ts with plot.type = "multiple". The only difference is that I
want a single box containing all the plots instead of one box per
plot. I thought box(which = "outer") would have done the job, but it
didn't. 
Below is the code I have used so far. (R 2.5.1, I know, I know...)
Any help is greatly appreciated. 
Thank you in advance,
Giovanni
=================
### Plot harmonic functions
n <- 6 # even
omega <- 2 * pi / n
par(mfrow = c(n - 1, 1), mar = c(0, 5.1, 0, 5.1), oma = c(3, 1, 2, 1))
for (i in 1:(n/2 - 1)) {
    curve(cos(x * i * omega), 0, n, ylim = c(-1.1, 1.1), ylab = "", axes = FALSE)
    points(1:n, cos(i * omega * 1:n))
    axis(2); abline(h = 0, col = "lightgrey")
    curve(sin(x * i * omega), 0, n, ylim = c(-1.1, 1.1), ylab = "", axes = FALSE)
    points(1:n, sin(i * omega * 1:n))
    axis(4); abline(h = 0, col = "lightgrey")
}
curve(cos(x * (n/2) * omega), 0, n, ylim = c(-1.1, 1.1), ylab = "", axes = FALSE)
points(1:n, rep(c(-1,1), n/2))
axis(1); axis(2); abline(h = 0, col = "lightgrey")
-- 
Giovanni Petris  <GPetris at uark.edu>
Department of Mathematical Sciences
University of Arkansas - Fayetteville, AR 72701
Ph: (479) 575-6324, 575-8630 (fax)
http://definetti.uark.edu/~gpetris/
    
    
More information about the R-help
mailing list