[R] how to print "<=" in plot title

David Winsemius dwinsemius at comcast.net
Tue Jun 28 20:04:07 CEST 2011


On Jun 28, 2011, at 1:52 PM, Peter Ehlers wrote:

> On 2011-06-28 10:25, array chip wrote:
>> Hi, how can I print "<=" (I mean the symbol of just one character)  
>> in the main
>> title of a plot?
>>
>> for example:
>>
>> plot(1:10, main=paste("x<=", x))
>>
>> where variable x is some number generated on the fly.
>
>  x <- 2.718
>  plot(0, 0)
>  title(bquote( x %<=% .(x) ))

I think John wants the mathematical symbol. As was pointed out in a  
question last week, the `<=` plotmath symbol needs to be flanked by  
operands. Non-printing operands can be created with the phantom  
function:

title(main=expression(phantom("")<=phantom("")) )

Contrary to Gunters's comment, this is probably going to work on all  
the three major OS platforms. It depends only on whether there is a  
Symbol font mapped to the output device.
>
> ?plotmath

Yes. The details are there.

>
> Peter Ehlers
>


David Winsemius, MD
West Hartford, CT



More information about the R-help mailing list