# [R] expression() - Superscript in y-axis, keeping line break in string

Andrew Kniss akniss at gmail.com
Fri Aug 4 18:44:35 CEST 2006

```Thank you Marc and Gabor.  Both suggestions work well.  I will use the
'atop' solution, as it requires the least amount of typing to change my
current ylabs.
Andrew

Marc Schwartz (via MN) wrote:
> Actually Gabor, using your solution with 'atop', which I had not
> considered, it will work with base graphics:
>
>  par(oma = c(0, 0, 2, 0), mar = c(5, 6, 0.25, 2), lheight = 1)
>
>  plot(1:10, ylab = expression(atop(" "^14*C*"-glyphosate line1",
>                                    line2)))
>
> HTH,
>
> Marc
>
> On Fri, 2006-08-04 at 12:09 -0400, Gabor Grothendieck wrote:
>> Sorry, you wanted a ylab=, not a main=.  Try using xyplot in lattice:
>>
>> library(lattice)
>> xyplot(1~1, ylab = expression(atop(phantom(0)^14*C*"-glyphosate line",
>> "line2")))
>>
>>
>> On 8/4/06, Gabor Grothendieck <ggrothendieck at gmail.com> wrote:
>>> Use atop:
>>>
>>>   plot(1, main = expression(atop(" "^14*C*"-glyphosate line", "line2")))
>>>
>>> On 8/4/06, Andrew Kniss <akniss at uwyo.edu> wrote:
>>>> I've tried several different ways to accomplish this, but as yet to no
>>>> avail.  My y-axis for a plot has a rather long label, and thus I have
>>>> been using "/n" to break it into two lines.  However, to make it
>>>> technically correct for publication, I also need to use superscript in
>>>> the label.  For example:
>>>>
>>>>     par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1)
>>>>     plot(1:10,
>>>>          ylab="14C-glyphosate line1\n line2")
>>>>
>>>> will provide the text in two lines as I would like it.  However, I am
>>>> trying to keep those same line breaks when using expression() to get my
>>>> superscript number.  This will not work, as it aligns the "14C" section
>>>> with the bottom line of the expression making little sense to the
>>>>
>>>>     par(oma=c(0,0,2,0),mar=c(5,6,0.25,2),lheight=1)
>>>>     plot(1:10,
>>>>          ylab=expression(" "^14*C*"-glyphosate line1\n line2"))
>>>>
>>>> Is there a way to align the "14C" portion of the expression with the top
>>>> line of the string rather than the bottom line?  Any suggestions are
>>>> greatly appreciated.
>>>> Andrew
>>>>
>

```