[R] help with plot layout
mauede at alice.it
mauede at alice.it
Wed Jan 28 16:51:35 CET 2009
It takes a lot of sweat to generate a composite plot with R ... sigh.
I though I was almost done when I met the umpteenth hurdle. I cannot place a nice title on the 2nd plot (raw signal)
on the layout. I do not have control on where either the "main" option of "plot" function, or "title", place the text
string which keeps dysplaying chopped from above. I also tried "text", changing many times the string coordinates, but could not see any text anywhere on the canvas .
By the way, since the layout breaks the canvas into 4 parts, are the text coordinates absolute (referred to the canvas) or
relative (referred to the part) ?
Please, find attached the generated drawing. The generating script is i the following.
Thank you so much,
Maura
##################################################################
WavMaxNumCoef <- 30
setwd("C:/Documents and Settings/Monville/SpAn-Tests/16440-Raw-Dir")
xx <- read.table("Interp-Amp-PhasePlus16440.txt",header=TRUE, sep=" ")
NumCycles <- max(xx[,"cycle"])
TickPos <- vector(length=NumCycles)
TickCoord <- vector(length=NumCycles)
for(i in 1:NumCycles) {
TickPos[i] <- xx[min(which(xx[,"cycle"] == i)),1]
}
aa <- read.table( "16440-Alpha.txt" )
xaa <- seq(1:length(t(aa)))
vv <- read.table("16440-Vanishing-Moments")
vvLab <- seq(1,WavMaxNumCoef/2,1)
vvCounts <- vector(length=WavMaxNumCoef/2)
for(k in 1:(WavMaxNumCoef/2)) {
vvCounts[k] <- length(which(vv[] == k))
}
yyLab <- seq(1,length(t(vv)),2)
bb <- read.table("16440-Length")
bbLab <- seq(min(bb),max(bb),1)
bb <- sort(t(bb))
bbCounts <- as.numeric(vector(length=(max(bb)-min(bb)+1)))
for(k in 1:length(bbCounts)) {
bbCounts[k] <- length(which(bb[] == (k +min(bb) -1)))
}
zzLab <- seq(1,max(bbCounts),1)
# DEFINE LAYOUT
x11(width=22,height=14)
nf <- layout(matrix(c(1,3,2,4),2,2,byrow=TRUE), c(3,1), c(2,2),FALSE)
layout.show(nf)
# PLOT DONOHO ALPHA
par(mar=c(10,4,2,5),xaxt="n",cex.axis=1,pty="m")
plot(xaa,t(aa),type="h")
par (xaxt="s",xaxp=c(0,95.964,24),xaxs="i")
axis(1,at=TickPos,labels=as.character(TickPos),col="red",col.axis="red",font.axis=1)
# PLOT RAW SIGNAL
par(mar=c(3,4,0,5),xaxt="n",cex.axis=1,pty="m")
plot(xx[,1],xx[,2],pch=3,type="l",frame.plot=FALSE,xpd=TRUE)
title("Raw Signal 16440",cex.main=1.0,font=2)
par (xaxt="s",xaxp=c(0,95.964,24),xaxs="i")
axis(1,at=TickPos,labels=as.character(TickPos),col="red",col.axis="red", font.axis=1)
# PLOT VANISHING MOMENT DISTRIBUTION
par(mar=c(1,0,2,3),xaxt="n",yaxt="n",cex.axis=0.7,pty="m")
barplot(vvCounts,width=1,space=0,horiz=TRUE,axes=FALSE)
par(xaxt="s",yaxt="s",crt=180,srt=270,adj=1,las=3,xpd=TRUE)
text(x=25.5,y=15.3,pos=4,"Wavelet Vanishing Moments Distribution",cex=1.0,font=2)
axis(2,at=vvLab-1,labels=as.character(vvLab),col="red",col.axis="red",font.axis=1,xpd=TRUE,
cex.lab=1)
axis(3,at=yyLab-1,labels=as.character(yyLab),col="red",col.axis="red",font.axis=1,xpd=TRUE,
cex.lab=0.8,cex.axis=0.8)
# PLOT CYCLES LENGTH
par(mar=c(0,0,1,3),xaxt="n",yaxt="n",cex.axis=1)
barplot(bbCounts,width=1,axes=FALSE,space=0,horiz=TRUE)
par(xaxt="s",yaxt="s",crt=180,srt=270,adj=1,las=3,cex.lab=0.1,xpd=TRUE)
text(x=15.5,y=65.3,pos=4,"Cycles Length Distribution",cex=1.0,font=2)
axis(2,at=as.numeric(bbLab)-41,labels=bbLab,col="red",col.axis="red",font.axis=1,
lab=c(10,10,15),cex.lab=0.7,cex.axis=0.6)
axis(3,at=zzLab,labels=as.character(zzLab),col="red",col.axis="red",font.axis=1,xpd=TRUE,
cex.lab=1,cex.axis=0.8)
# cords <-locator(n=3)
e tutti i telefonini TIM!
Vai su
More information about the R-help
mailing list