1

I'm making plots in R, and I want my title to show the species name in italics (e.g. Sterna hirundo) when I run a loop. This is the code I've tried to use.

title(expression(italic(specieslist[i])))

All this does is print specieslist[i]. How can I get it to print the actual species name?

Thanks

Onik
  • 19,396
  • 14
  • 68
  • 91
  • [search](http://stackoverflow.com/questions/4302367/concatenate-strings-and-expressions-in-a-plots-title) or [search](http://stackoverflow.com/questions/20532136/expression-variable-value-normal-text-in-plot-maintitle)? – rawr Nov 28 '15 at 13:54
  • Neither of those help, I've already tried pasting but my problem is something to do with italic() not being a function but an expression. – Josh Marchant Nov 28 '15 at 15:11
  • well if all you want is the whole title in italics, doesn't `title(specieslist[i], font.main = 3)` work? no need for expressions – rawr Nov 28 '15 at 15:27
  • That helps somewhat, but what if I only wanted the species name to be in italics? e.g. "_Sterna hirundo_ temperature regression". Thanks for your help – Josh Marchant Nov 28 '15 at 16:08
  • you can paste like the duplicate linked question, or you can do this which I think is a lot easier than figuring out bquote and expression/as.expression `plot(1); for (ii in 'setosa') title(parse(text = sprintf('species~italic(%s)', ii)))` – rawr Nov 28 '15 at 23:53

0 Answers0