[R] maths characters in labels & ylab padding
Mike Meredith
mmeredith at wcs.org
Mon Jul 23 08:56:04 CEST 2007
Help on this is in
?plotmath
You can use
ylab = expression("Y Label " (m^2))
Use par(mar..) to increase the margin width, and then mtext to place y axis
label:
y <- 1:10
x <- rnorm(10,50000,2000)
par(mar = c(5,6,4,2) + 0.1)
plot(x ~ y,
ylab = "",
las = 1,
type = "n",
bty = "n"
)
mtext(expression("Y Label " (m^2)), side = 2, line = 4)
If you use this within a function, you'll probably want to reset the margins
on exit:
old.mar <- par(mar = c(5,6,4,2) + 0.1) ; on.exit(par(old.mar))
HTH, Mike.
Murray Pung wrote:
>
> I have checked out the help files, but cannot find details on how to use
> maths characters in ylab. Instead of m^2, I would like the 2 in
> superscript,
> if possible. I would also like to place more padding on the label so that
> the label is not obscured by the horizontal numbers.
>
>
> y <- 1:10
> x <- rnorm(10,50000,2000)
> plot(x ~ y,
> ylab = 'Y Label (m^2)',
> las = 1,
> type = "n",
> bty = "n"
> )
>
>
> Thanks
> Murray
>
> --
> Murray Pung
> Statistician, Datapharm Australia Pty Ltd
> 0404 273 283
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch 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.
>
>
--
View this message in context: http://www.nabble.com/maths-characters-in-labels---ylab-padding-tf4127592.html#a11738746
Sent from the R help mailing list archive at Nabble.com.
More information about the R-help
mailing list