Dear all, I have a rather complicated problem. I am trying to loop through making graphs, so that the graph-making process is fully automated. For each graph, I'd like to make sure the corresponding title is formatted properly. The titles will be a combination of a gene name and numerical position within the gene. The gene name should be italic-bold, whereas the gene position should be just bold. Consider the following: x <- read.table(textConnection("gene position FLC 3312 TFL1 687 GA1 1127"), header = TRUE, as.is = TRUE) closeAllConnections() Now this, below, is essentially how I am automating the graph-making (imagine these graphs contain some sort of real data): par(mfrow = c(3,1)) for (i in 1:nrow(x)){ plot(z <- sort(rnorm(47)), type = "s", main = "") points(z, cex = .5, col = "dark red") title(main = paste(x[i,1], " p", x[i,2], sep = "")) } The graphs produced by this method are almost perfect, except that the gene names are not italicized (they SHOULD be). So, once again, the big question is: how would I italicize the gene names but NOT the gene positions, when looping through to make these graphs and graph titles? If I WASN'T looping to make my graph titles, I could write: title(main = expression(paste(bolditalic("FLC"), bold("p3312"), sep = " "))) ...but I can't do that, because I'm looping (or can I?) Thanks in advance for your help! ----------------------------------- Josh Banta, Ph.D Center for Genomics and Systems Biology New York University 100 Washington Square East New York, NY 10003 Tel: (212) 998-8465 http://plantevolutionaryecology.org [[alternative HTML version deleted]]
On Feb 19, 2011, at 7:41 PM, Josh B wrote:> Dear all, > > I have a rather complicated problem. I am trying to loop through > making graphs, > so that the graph-making process is fully automated. For each graph, > I'd like to > make sure the corresponding title is formatted properly. The titles > will be a > combination of a gene name and numerical position within the gene. > The gene name > should be italic-bold, whereas the gene position should be just bold. > > Consider the following: > > x <- read.table(textConnection("gene position > FLC 3312 > TFL1 687 > GA1 1127"), header = TRUE, as.is = TRUE) > closeAllConnections() > > Now this, below, is essentially how I am automating the graph-making > (imagine > these graphs contain some sort of real data): > > par(mfrow = c(3,1)) > for (i in 1:nrow(x)){ > plot(z <- sort(rnorm(47)), type = "s", main = "") > points(z, cex = .5, col = "dark red") > title(main = paste(x[i,1], " p", x[i,2], sep = "")) > }bquote is your friend (at least if one wants to use expressions rather than text): for (i in 1:nrow(x)){ plot(z <- sort(rnorm(47)), type = "s", main = "") points(z, cex = .5, col = "dark red") title(main = bquote(italic(.(x[i,1])*" p"*.(x[i,2])))) } -- David.> > The graphs produced by this method are almost perfect, except that > the gene > names are not italicized (they SHOULD be). > > > So, once again, the big question is: how would I italicize the gene > names but > NOT the gene positions, when looping through to make these graphs > and graph > titles? If I WASN'T looping to make my graph titles, I could write: > > title(main = expression(paste(bolditalic("FLC"), bold("p3312"), sep > = " "))) > > ...but I can't do that, because I'm looping (or can I?) > > Thanks in advance for your help! > > ----------------------------------- > Josh Banta, Ph.D > Center for Genomics and Systems Biology > New York University > 100 Washington Square East > New York, NY 10003 > Tel: (212) 998-8465 > http://plantevolutionaryecology.org > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.David Winsemius, MD West Hartford, CT
On Feb 19, 2011, at 7:41 PM, Josh B wrote:> Dear all, > > I have a rather complicated problem. I am trying to loop through > making graphs, > so that the graph-making process is fully automated. For each graph, > I'd like to > make sure the corresponding title is formatted properly. The titles > will be a > combination of a gene name and numerical position within the gene. > The gene name > should be italic-bold, whereas the gene position should be just bold. > > Consider the following: > > x <- read.table(textConnection("gene position > FLC 3312 > TFL1 687 > GA1 1127"), header = TRUE, as.is = TRUE) > closeAllConnections() > > Now this, below, is essentially how I am automating the graph-making > (imagine > these graphs contain some sort of real data): > > par(mfrow = c(3,1)) > for (i in 1:nrow(x)){ > plot(z <- sort(rnorm(47)), type = "s", main = "") > points(z, cex = .5, col = "dark red") > title(main = paste(x[i,1], " p", x[i,2], sep = "")) > } >Or perhaps (with a shuffling of the parens): for (i in 1:nrow(x)){ plot(z <- sort(rnorm(47)), type = "s", main = "") points(z, cex = .5, col = "dark red") title(main = bquote(italic(.(x[i,1]))*" p"*.(x[i,2]))) }> The graphs produced by this method are almost perfect, except that > the gene > names are not italicized (they SHOULD be). > > > So, once again, the big question is: how would I italicize the gene > names but > NOT the gene positions, when looping through to make these graphs > and graph > titles? If I WASN'T looping to make my graph titles, I could write: > > title(main = expression(paste(bolditalic("FLC"), bold("p3312"), sep > = " "))) > > ...but I can't do that, because I'm looping (or can I?) > > Thanks in advance for your help! > > ----------------------------------- > Josh Banta, Ph.D > Center for Genomics and Systems Biology > New York University > 100 Washington Square East > New York, NY 10003 > Tel: (212) 998-8465 > http://plantevolutionaryecology.org > > > > [[alternative HTML version deleted]] > > ______________________________________________ > R-help at 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.David Winsemius, MD West Hartford, CT
Follow-up question: I want to make the gene name bold and italic, AND make the "p" number just bold. But here's the catch: now I want the "p" number to appear as a superscript! For instance: TFL1^687 (the carrot is to indicate that I actually want the "p" number as a superscript). Thanks very much in advance! Sincerely, Josh Banta ________________________________ From: David Winsemius <dwinsemius@comcast.net> Sent: Sat, February 19, 2011 10:24:03 PM Subject: Re: [R] Partial italic in graph titles when looping On Feb 19, 2011, at 8:52 PM, Josh B wrote:> Follow-up question: how would I make the gene name italic AND bold, and how >would I make the " p" and the number just bold?Could also work inside teh .() function for (i in 1:nrow(x)){ plot(z <- sort(rnorm(47)), type = "s", main = "") points(z, cex = .5, col = "dark red") title(main = bquote(italic(.(x[i,1]))*bold(" p")*bold(.(as.character(x[i,2]))))) }> > From: David Winsemius <dwinsemius@comcast.net>> Cc: R Help <r-help@r-project.org> > Sent: Sat, February 19, 2011 8:33:33 PM > Subject: Re: [R]Partial italic in graph titles when looping > > > On Feb 19, 2011, at 7:41 PM, Josh B wrote: > > > Dear all, > > > > I have a rather complicated problem. I am trying to loop through making >graphs, > > so that the graph-making process is fully automated. For each graph, I'd like >to > > make sure the corresponding title is formatted properly. The titles will bea> > combination of a gene name and numerical position within the gene. The gene >name > > should be italic-bold, whereas the gene position should be just bold. > > > > Consider the following: > > > > x <- read.table(textConnection("gene position > > FLC 3312 > > TFL1 687 > > GA1 1127"), header = TRUE, as.is = TRUE) > > closeAllConnections() > > > > Now this, below, is essentially how I am automating the graph-making(imagine> > these graphs contain some sort of real data): > > > > par(mfrow = c(3,1)) > > for (i in 1:nrow(x)){ > > plot(z <- sort(rnorm(47)), type = "s", main = "") > > points(z, cex = .5, col = "dark red") > > title(main = paste(x[i,1], " p", x[i,2], sep = "")) > > } > > > Or perhaps (with a shuffling of the parens): > for (i in 1:nrow(x)){ > plot(z <- sort(rnorm(47)), type = "s", main = "") > points(z, cex = .5, col = "dark red") > title(main = bquote(italic(.(x[i,1]))*" p"*.(x[i,2]))) > } > > > The graphs produced by this method are almost perfect, except that the gene > > names are not italicized (they SHOULD be). > > > > > > So, once again, the big question is: how would I italicize the gene namesbut> > NOT the gene positions, when looping through to make these graphs and graph > > titles? If I WASN'T looping to make my graph titles, I could write: > > > > title(main = expression(paste(bolditalic("FLC"), bold("p3312"), sep = " "))) > > > > ...but I can't do that, because I'm looping (or can I?) > >[[elided Yahoo spam]]> > > > ----------------------------------- > > Josh Banta, Ph.D > > Center for Genomics and Systems Biology > > New York University > > 100 Washington Square East > > New York, NY 10003 > > Tel: (212) 998-8465 > > http://plantevolutionaryecology.org > > > > > > > > [[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. > > David Winsemius, MD > West Hartford, CT > > >David Winsemius, MD West Hartford, CT [[alternative HTML version deleted]]