Subversion Repositories bdplot

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

Rev Author Line No. Line
46 pb 1
## PB 20101110: For plotting many plots with one x-axis.
2
## Split this into two function, e.g. plotOneXAxisBegin og plotOneXAxisEnd.
3
 
4
##------------------------------------------------------------------------
5
## The number of plots in the figure
6
n <- 
7
## Make the figure layout
8
## The first element to heights is the upper "margin", the last is the lower "margin"
9
layout(1:(n+2), heights=c(lcm(0.1), rep(1,n), lcm(1))) 
10
## Set par. Note xaxt="n" here, and in the last plot xaxt="s" 
11
par(mar=c(0,3,0,1), xaxt="n", mgp=c(2,0.7,0))         
12
## The top margin plot is empty. 
13
plot(0, type="n", xaxt="n", yaxt="n", bty="n", xlab="", ylab="")
14
## Do n plots of what you want, make xlab=""
15
plot(D$t, D$x, xlab="", ylab="x (kW)")
16
...
17
 
18
##------------------------------------------------------------------------
19
## The last plot to fill the lower "margin"
20
plot(D$t, D$y, xaxt="s", xlab="Time", ylab="y (C)")
21
## xlab text
22
mtext("Time", 1, line=2, cex=par("cex"))
23