I would like my axis label to read something like
(m²)
with the height of the parentheses a little larger to match the superscript 2, but the parentheses nonetheless inline.
However, I either get parentheses that are too small, via something like
parse(text='group("(",m^{2},")")')
which yields
or parentheses that are too big and out-of-line, via something like
parse(text='bgroup("(",m^{2},")")')
which yields
Can I not do this in R?
Update:
As per the suggestion of user @42-, I've also tried scriptstyle
. However, this makes the parenthesized text much smaller. It's particularly noticeable with neighboring text. For instance,
parse(text='Area~~(scriptstyle(m^{2}))')
would yield
I realize the workaround would be using something like
parse(text='scriptstyle(Area~~(m^{2}))')
which yields
and then manually upscaling font size to compensate, but is there a fix or alternative that won't require this kind of guesstimation?
Do you want;
plot(1,1, main=parse(text='scriptstyle( bgroup("(",m^{2},")"))') )
Or perhaps:
plot(1,1, main=parse(text='"("*scriptstyle(m^{2})*")"') )
A third altermative is to use "phantom()" which will reserve space equivalent to its argument. I found by experimentation that you could get parentheses that were not so "descend-ful" using:
plot(1,1, main=parse(text='"("*phantom(m^2)*")"') ,cex.main=1.6)
And then filling in the gap with:
title(main=expression(m^2) )
And it further twerking is needed, one can adjust the level of text relative to the "box" in units of text lines with title(main= <expression> , line= 2.5)
plot(1,1) ; title( main=expression(Area(phantom(" "))) ,cex.main=1.5, line=1.5)
title(main=expression(phantom('Area(')*m^2) ,line=1.5)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With