[R] square brackets in expression in plots

Duncan Murdoch murdoch.duncan at gmail.com
Tue Jul 20 20:07:37 CEST 2010


On 20/07/2010 12:42 PM, Jannis wrote:
> Dears,
>
>
> do you know whether it is possible to include any square parantheses (brackets) in an expression to use it as an axis label?
>
> e.g. I would like to have a label like (with the sub and superscripts correct):
>
> "speed [m s^-1]"
>
> I know how to combine an expression with text via paste, but as I run soimething like:
>
> a='m*s^{-1}'
> plot(1:10,main=parse(text=a))
>
> I found now way of doing this. I use the parse thing as I have all these units stored as strings that represent expressions.
>
>   
plot(1,1, main=expression(paste("speed [", m * s^{-1}, "]")))

Duncan Murdoch



More information about the R-help mailing list