Here's my version of the technicolor title function: multiTitle <- function(...){ ### ### multi-coloured title ### ### examples: ### multiTitle(color="red","Traffic", ### color="orange"," light ", ### color="green","signal") ### ### - note triple backslashes needed for embedding quotes: ### ### multiTitle(color="orange","Hello ", ### color="red"," \\\"world\\\"!") ### ### Barry Rowlingson <b.rowling...@lancaster.ac.uk> ### l = list(...) ic = names(l)=='color' colors = unique(unlist(l[ic]))
for(i in colors){ color=par()$col.main strings=c() for(il in 1:length(l)){ p = l[[il]] if(ic[il]){ # if this is a color: if(p==i){ # if it's the current color current=TRUE }else{ current=FALSE } }else{ # it's some text if(current){ # set as text strings = c(strings,paste('"',p,'"',sep="")) }else{ # set as phantom strings = c(strings,paste("phantom(\"",p,"\")",sep="")) } } } # next item ## now plot this color prod=paste(strings,collapse="*") express = paste("expression(",prod,")",sep="") e=eval(parse(text=express)) title(e,col.main=i) } # next color return() } ______________________________________________ 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.