[R] two lines in axis title combined with 'substitute' command

David Winsemius dwinsemius at comcast.net
Thu Jan 3 17:28:19 CET 2013


On Jan 3, 2013, at 8:00 AM, Uwe Ligges wrote:

>
>
> On 03.01.2013 15:00, N.Hubner at ncmls.ru.nl wrote:
>> Hello,
>>
>> I want to have the x-axis title of my plot in 2 lines, centered:
>>
>> experiment 1:
>> log2(Ratio H/L)
>>
>> I know that in principle that works with '\n'. However, I am also  
>> using the 'substitute' command for my axis title. However, it does  
>> not make a new line.
>
> You cannot.

That has been my experience and I believe it is documented on the  
help(plotmath) page.

> One way out is to use two calls to title(xlab=...., line=...), one  
> for each line of the xlab title.

Another way would be with the use of the 'atop' function.

  substitute( atop(
          log[logbase]* ("Ratio L"/"H reverse"),
          italic("experiment 2")
                    ), list(logbase=logbase)
               )
Returns:

atop(log[2] * ("Ratio L"/"H reverse"), italic("experiment 2"))


-- 
David.
>
> Best,
> Uwe Ligges
>
>
>>
>> What I have so far:
>>
>> logbase <- 2
>> test <- "bait"
>> cellline <- "cellline"
>>
>> plot(
>> log(filteredproteins[["Ratio.H.L.normalized.UW21_FW"]],base=logbase),
>> - 
>> log 
>> (filteredproteins[["Ratio.H.L.normalized.UW21_REV"]],base=logbase),
>> main= substitute("bait = "* bait *" in "*cellline, list(bait=bait,  
>> cellline=cellline)),
>> xlab = substitute(
>> log[logbase]*
>> ("Ratio H"/"L forward")*
>> italic("\n experiment 1"),
>> list(logbase=logbase)
>> ),
>> ylab = substitute(
>> log[logbase]*
>> ("Ratio L"/"H reverse")*
>> italic("\n experiment 2"),
>> list(logbase=logbase)
>> ),
>> col="lightblue",
>> bg="black",
>> pch=16
>> )
>>
>> Thanks for your help!
>> Nina
>>
>>
>>
>> The Radboud University Nijmegen Medical Centre is listed in the  
>> Commercial Register of the Chamber of Commerce under file number  
>> 41055629.
>>
>>
>> 	[[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.
>>
>
> ______________________________________________
> 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
Alameda, CA, USA




More information about the R-help mailing list