Now that I have my list of flags with theri respective values (thanks to all those who posted their suggestions):
Flags Values 1 TrendOff 0 2 MOdwt 1 3 ZeroPadding 1 4 Step1HSOff 1 5 Step1NumHSOff 4 6 Step1NumHSOff 1 7 Step1ExtOff 1 8 Step2HSOff 1 9 Step2NumHSOff 4 10 Step2NumHSOff 1 11 Step2ExtOff 1 12 Step3HSOff 1 13 Step3NumHSOff 4 14 Step3NumHSOff 1 15 Step3ExtOff 1 16 Step4HSOff 1 17 Step4NumHSOff 4 18 Step4NumHSOff 1 19 Step4ExtOff 1 The next step is to insert the above list in a composite plot made up of 4 quadrants. The top 2 quadrants are filled with a barplot, the bottom left quadrant is filled with a 2-tracks plot. I would like to place the flags list in the bottom right quadrant. Hiow can I do that ? Maybe through using the text command recursively (once for each flag pairlist) ? Please, notice taht what none of the graphs represent the flags value. Therefore a legend is unappropriate here. Here is a sketched incomplete and undebugged script to generate the composite plot I mentioned: alpha <- matrix(nrow=21,ncol=2,byrow=T) zm <- matrix(nrow=10,ncol=2,byrow=T) colnames(alpha) <- c("MEM","SpAn") colnames(zm) <- c("MEM","SpAn") alpha[,1] <- c( 0.9453125, 1, 1, 1, 0.9765625, 0.9973958, 0.9375, 0.9921671, 0.9765625, 0.9322917, 0.96875, 0.8645833, 0.8723958, 0.9270833, 0.9791667, 0.9869792, 0.9661458, 0.9895833, 1, 1, 0.9713542 ) alpha[,2] <- c( 0.7265625, 0.8828125, 0.7734375, 0.7734375, 0.6875, 0.8359375, 0.6484375, 0.8046875, 0.71875, 0.734375, 0.71875, 0.7265625, 0.6796875, 0.7265625, 0.6953125, 0.6953125, 0.703125, 0.7890625, 0.828125, 0.8359375, 0.8515625 ) zm[,1] <- c( 0.857, 0, 0, 0, 0.0476, 0, 0.0476, 0, 0, 0.0476 ) zm[,2] <- c( 0, 0, 0, 0.762, 0, 0.0476, 0.1904, 0, 0, 0 ) flags_val <- c( 0,1,1,1,4,1,1,1,4,1,1,1,4,1,1,1,4,1,1) flags_nam <- c("TrendOff","MOdwt","ZeroPadding", "Step1HSOff","Step1NumHSOff","Step1NumHSOff","Step1ExtOff", "Step2HSOff","Step2NumHSOff","Step2NumHSOff","Step2ExtOff", "Step3HSOff","Step3NumHSOff","Step3NumHSOff","Step3ExtOff", "Step4HSOff","Step4NumHSOff","Step4NumHSOff","Step4ExtOff" ) flags <- data.frame(Flags=flags_nam, Values=flags_val,stringsAsFactors=FALSE) par(mfrow=c(2,2)) barplot(zm[,1],width=1,space=0,horiz=FALSE,axes=FALSE,main="MEM Vanishing Moments Distribution",cex.main=0.95) xxLab <- seq(0,11,1) axis(1,at=xxLab-0.5,labels=as.character(xxLab),col="red",col.axis="red",font.axis=1,xpd=TRUE, cex.lab=1) yyLab <- seq(0,1,0.14) axis(2,at=yyLab,labels=as.character(yyLab),col="red",col.axis="red",font.axis=1,xpd=TRUE, cex.lab=0.8,cex.axis=0.8) barplot(zm[,2],width=1,space=0,horiz=TRUE,axes=FALSE) text(x=25.5,y=15.6,pos=4,"SpAn Vanishing Moments Distribution",cex=1.2,font=2) axis(2,at=xxLab-1,labels=as.character(xxLab),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) cycle <- seq(1,21,1) plot(cycle, alpha[,1], pch=1, type = "l", col=3, lty=2, main="Alpha") points(cycle, alpha[,2], pch=3, type="b", lty=1, pch=4, col=6) legend("topright", legend=c("MEM","SpAn"), col=c(3,6),text.col="green4",lty=c(2,1), pch=c(1,3),merge=FALSE, bg='gray90') Thank tyou so much. Maura -----Messaggio originale----- Da: baptiste auguie [mailto:ba...@exeter.ac.uk] Inviato: ven 20/03/2009 12.56 A: mau...@alice.it Cc: r-help@r-project.org Oggetto: Re: [R] Multi-line texts in plots Hi, it would help if you provided a minimal example. Here is one approach I often use with the plotting package ggplot2, parameters <- expand.grid(m=c(0, 1), s=seq(0.1, 1,length=10)) x <- seq(-5, 5, length=300) foo <- function(m, s){ data.frame(x=x, y=dnorm(x, m, s), m=factor(m), s=factor(s)) } # construct a data.frame with all the data results <- do.call(rbind, mapply(foo, m=parameters$m, s=parameters$s, SIMPLIFY=F)) library(ggplot2) p1 <- qplot(x, y, data=results, geom="line", colour=s, linetype=m) p2 <- p1 + facet_grid(m~.) results2 <- within(results, f <- factor(paste("m=", m,"; s=", s))) p3 <- qplot(x, y, data=results2, geom="line", colour=f) p1 # note how the legend is constructed for you p2 # clearest imho p3 # with 20 levels it's not very readable Hope this helps, baptiste On 20 Mar 2009, at 10:59, mau...@alice.it wrote: > I am running a simulation many times changing one parameter each > time and recording the outcome. > I have to produce a plot to make a sense of the bunch of numbers I > get from every run. > My problem is to insert a multi-line text to keep track of which > result correspond to which parameter values. > A legend does not work in this case because I will plot 2 variables > and the corresponding experimental values. > So two curves on the same drawing as a result of the combination of > 20 parameters. > I may decide to place two plots on the same canvas but if so I will > have to find the space for two 20-line texts .... > In short, I wonder how I can insert a 20-line text on each plot. I > browsed through the documentation of the par command > but I could not find any helpful option. > Thank you in advance for any suggestion. > Maura > > > tutti i telefonini TIM! > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting-guide.html > and provide commented, minimal, self-contained, reproducible code. _____________________________ Baptiste AuguiƩ School of Physics University of Exeter Stocker Road, Exeter, Devon, EX4 4QL, UK Phone: +44 1392 264187 http://newton.ex.ac.uk/research/emag ______________________________ tutti i telefonini TIM! [[alternative HTML version deleted]]
______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.