[R] control point size of superscript when labeling axes with title()

David Winsemius dwinsemius at comcast.net
Wed Dec 5 02:19:27 CET 2012


On Dec 4, 2012, at 11:05 AM, Chris Solomon wrote:

> Hi-
> 
> A journal has asked me to make all of my text annotations on a figure at 10-point size. For the most part this is easy, e.g. by creating figures with:
>   pdf(..., family='Times', pointsize=10)
> 
> But where I have superscripts (or subscripts) in axis labels, the default seems to be to shrink the superscripted text slightly. For example this code:
>   title(ylab=expression(paste('Respiration (mg  ',O[2],'  ',L^-1,' ',d^-1,')',sep=' ')),outer=T,line=0.3)
> produces superscripted numbers at approximately 7 point.
> 
> I have been poking around for a solution but not having much luck. The textstyle() function keeps superscripted text at original size if you use it within a text() call, but I can't figure out an equivalent solution within a title() call.

It is not the fact that you are using title, but rather (I think) the fact that numbers are handled differently than text in plotmath. You are also unnecessarily using 'paste' and incorrectly including 'sep' argument in plotmath-paste, which does not honor that argument. 

Regular R-paste != plotmath-paste

Quoting the exponents allows textstyle to do its job properly. 

> plot(1,1, ylab="")
> title(ylab = expression(Respiration~"("*mg~~O[2]~~L^textstyle("-1")~d^textstyle("-1")*')') ,line= 1.5)

> 	[[alternative HTML version deleted]]
> 
You might want to read what the Posting Guide says about HTML posting.

> 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
Alameda, CA, USA




More information about the R-help mailing list