0

Any simple way to show exponents in graph titles or axis labels? Right now I have something like ylab="r^2". Is there any way to show 2 as the exponent of r? I mean graphically, for the number 2 to be smaller and at the top right corner of the letter r.

Thanks, Adrian

AdrianP.
  • 435
  • 2
  • 4
  • 14
  • 1
    just use `ylab=expression(r^2)`. See the `?plotmath` help page for additional information. – MrFlick Jan 18 '15 at 17:35
  • Thanks! Works for ylab, but for some reason doesn't work for title, I tried ...main=paste("Mean", expression(r^2), round(mean(a18[(which(a18[,1] >= 0 & a18[,1] <= 193190)),15]), digits=2)) and it displays as r^2. Odd. – AdrianP. Jan 18 '15 at 17:58
  • Well, that's really a different problem and I think you'll find an answer here: http://stackoverflow.com/questions/4423130/use-a-variable-within-a-plotmath-expression – MrFlick Jan 18 '15 at 19:00
  • In that post, he is trying to actually call the value of the variable, and place it in the title, is that not correct? For me that's not it, this is what I have: http://pelinfamily.ca/biostars/variable_r%5E2.png the yaxis is perfect, shows r and exponent 2, in the title however it still shows r^2. – AdrianP. Jan 18 '15 at 19:05
  • Well it seems you are trying to calculate a value, right? Or do you literally want that code in the title? If you just want the numeric value, the your problem is the same as the other question. – MrFlick Jan 18 '15 at 19:07
  • for me the calculation is not an issue, it is done already, as you can see 0.52 is the calculated value, that's fine. My question is purely graphical, the yaxis if I set ylab=expression(r^2), r^2 shows how it's supposed to, with the "2" being an exponent on top right of letter "r". I want the exact same thing for the main title, i want it to say r^2 like it does for the yaxis, without the "^". – AdrianP. Jan 18 '15 at 19:14
  • I suggest you more closely follow that answer. You need to build an expression, not a Chester value. You have paste() on the outside which converts everything to character. You should be using bquote() or substitute() to make an expression. – MrFlick Jan 18 '15 at 19:26

0 Answers0