[R] expression() and font.lab ?

David Winsemius dwinsemius at comcast.net
Fri Apr 27 23:44:42 CEST 2012


converted formated text to plain text.
On Apr 27, 2012, at 3:52 PM, Aparna Radhakrishnan wrote:

> Hi...sorry that my question seemed incomplete.
>
> The plotting code :
> par
> (cex
> .axis
> =
> 0.8,las=1,font.lab=2,font.axis=2,family="sans",mgp=c(2,1,0),mar=c(3,  
> 3, 4, 2)+0.1)
> plot(A$pos,-log(A$GPVI_frequentist_add_Batch_expected_pvalue, 
> 10),col=A$R2class,pch=A 
> $pch,xlim=c(161160087,161214038),ylim=c(0,7),xlab="Genomic  
> position",ylab=expression(-log[10]~(P-value)))
>

Well, since you didn't give the data, most of that plot argument is  
superfluous. Lets just use plot(1,1) as out staring point.  Plotmath  
expression interpetation of the font choices among plain, bold and  
italic are controlled by plotmath functions, so:

plot(1,1, ylab=expression( bold(-log[10]~(P-value) ) ) )

Now, thinking as the plotmath interpreter which considers "-" to be  
meaningful and then back as a human interpreter, I would suggest that  
you also consider whether this is what you really wanted:

plot(1,1, ylab=expression(bold(-log[10]~(P*"-"*value))) ) # no spaces  
fore and aft of the minus sign

Noting that one needs to quote the minus sing to prevent its  
interpretation as as minus sign. Or perhaps (thinking now as a human- 
plotmath hybrid):

plot(1,1, ylab=expression(bold(-log[bold("10")]~(P*"-"*value))) )


(Note that I suggested earlier that there _was_ a way to get numbers  
bold()-ed.)

-- 
David.

> I am using a MacBook Pro and I have the R 2.15.0 . I have used only  
> the base-graphics and not loaded any other libraries.
>
> Hope that completes the question.
>
> Please also find the plot attached here. Note the y-axis label is  
> not in bold face or in "sans" font.
>
> Regards,
> Aparna.
>
> <FCER1G_locus_association.jpeg>
> On 27 Apr 2012, at 19:36, David Winsemius wrote:
>
>>
>> On Apr 27, 2012, at 11:22 AM, aparna15 wrote:
>>
>>> Hi..
>>>
>>> I managed to use expression() for superscripting and subscripting  
>>> values in
>>> my axis labels.
>>
>> What's missing here is your plotting code and your machine and R  
>> installation details. You may want to review the Posting Guide for  
>> what is requested. Plotting issues are more machine dependent than  
>> other aspects. Since the ?plotmath page does have details that  
>> include:
>>
>> "The fonts used are taken from the current font family, and so can  
>> be set by par(family=) in base graphics, and gpar(fontfamily=) in  
>> package grid.
>>
>> Note that bold, italic and bolditalic do not apply to symbols, and  
>> hence not to the Greek symbols such as mu which are displayed in  
>> the symbol font. They also do not apply to numeric constants."
>>
>> ... my speculation is that you may not be using base graphics or  
>> you may have excessive expectations regarding how symbols are  
>> displayed. You can sometimes get around that last limitation by  
>> using character values where you want numeric values in bold or  
>> italic. Again, we need full details. Put together a reproducible  
>> example and repost.
>>
>> -- 
>> David
>>
>>
>>> However, I notice that the font and style that I had passed
>>> through par() are ignored.
>>>
>>> I used :
>>> par(font.lab=2, font=2, family="sans")
>>>
>>> but when I employ expression() for my xlab, the styling given  
>>> above is
>>> completely ignored.
>>>
>>> I would greatly appreciate it if someone knew of a method of  
>>> maintaing the
>>> style while superscripting or subscripting in an axis label.
>>>
>>> Regards,
>>> Aparna.
>>>
>>>
>>
>

David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list