[R] scalable < > delimiters in plotmath

David Winsemius dwinsemius at comcast.net
Sun Sep 12 22:43:09 CEST 2010


On Sep 12, 2010, at 4:11 PM, Paul Murrell wrote:

> Hi
>
> On 13/09/2010 7:57 a.m., baptiste auguie wrote:
>> Oh, right I see. I was completely off then. Maybe it's not so easy to
>> add<>  delimiters after all, I'll have to look at the list of symbol
>> pieces to see if these can be constructed too.
>
> The plotmath stuff assumes a font with an Adobe Symbol encoding.   
> The characters we have to play with are shown at http://www.stat.auckland.ac.nz/~paul/R/CM/AdobeSym.pdf 
> .
> You can see the components of "growable" delimiters on the bottom  
> two rows.

Hello Paul;

Both Baptiste and I have looked at the plotmath.c code and it appears  
that only a few of those delimiters are supported. We specifically  
have tried to use the angle brackets:

 > plot(1,1,  
xlab=expression(bgroup(symbol(0xe1),atop(x,y),symbol(0xf1))))
Error in bgroup(symbol(225), atop(x, y), symbol(241)) :
   invalid group delimiter

The supported delimiters appear to each be built up from three parts  
that are then assembled within a bounding box and as far as I can  
determine are limited to "|", "||", "[", "{", "(", ")", "}",and "}". I  
needed to download the full source to find a copy, but I'm fairly sure  
a guRu of your standing needs no help finding the code that handles  
the bgroup display inside plotmath.c. I am not at my machine where I  
was looking at it, but the code that I just found in expanded form on  
the Internet bore your name as a copyright holder.

So I guess my feature request would be:
---add option for using scalable single character delimiters such as  
Symbol(0xe1) and Symbol(0xe1).

I'm guessing that the reason three-component delimiters were chosen is  
that it was easier to expand the middle section while not expanding  
the ends as much but that's just the guess of someone who is perusing  
without really being able to fully grasp the intricacies of what is  
being done.

-- 
David

>
> Paul
>
>> Thanks,
>>
>> baptiste
>>
>> On 12 September 2010 21:42, David  
>> Winsemius<dwinsemius at comcast.net>  wrote:
>>>
>>> On Sep 12, 2010, at 6:15 AM, baptiste auguie wrote:
>>>
>>>> Thanks everyone. I've also had a look at plotmath.c where bgroup is
>>>> defined for "[", "{", "(", "." but not "<". It seems quite  
>>>> trivial to
>>>> add it, at first sight, however there is a part that I don't
>>>> understand in the RenderDelim routine,
>>>>
>>>> static BBOX RenderDelim(int which, double dist, int draw,  
>>>> mathContext *mc,
>>>>                        pGEcontext gc, pGEDevDesc dd)
>>>> {
>>>>
>>>> // [... snipped ...]
>>>>
>>>>   case '(':
>>>>        top = 230; ext = 231; bot = 232; mid = 0;
>>>>        break;
>>>>   case ')':
>>>>        top = 246; ext = 247; bot = 248; mid = 0;
>>>>        break;
>>>>
>>>> These integer codes make no sense to me, I have no clue which  
>>>> ones I
>>>> should use for<  and>.
>>>
>>> Does this help? (I think they are using Symbol PS fonts with decimal
>>> indexing.)
>>>
>>>> as.octmode(c(230, 231, 232, 246, 247, 248) )
>>> [1] "346" "347" "350" "366" "367" "370"
>>>  plot(1,1, xlab= expression(
>>> symbol("\346")~    # upper 1/3 of left paren
>>> symbol("\347")~    # to left of center bar
>>> symbol("\350")~    # lower 1/3 of left paren
>>>
>>> symbol("\366")~    # upper 1/3 of right paren
>>> symbol("\367")~    # to right of center bar
>>> symbol("\370") ) ) # lower 1/3 of right paren
>>>
>>> (caveat: Maybe not standard glyph-names.)
>>>
>>> I added octal annotation to the TestChars(font=5) call that the  
>>> points help
>>> page offers:
>>>
>>> TestChars(font=5)
>>> for(j in 1:14) {
>>>    for(i in 0:16){
>>>        text(i+0.2, j+.6, labels=as.octmode(i+(j+1)*16), cex=.5)}}
>>>
>>> I do not see a trio or pair of glyphs that would form an angle  
>>> bracket.
>>>
>>> --
>>>
>>> David.
>>>
>>>
>>>> As far as I understand these codes might
>>>> correspond to extended ascii characters whose boundaries and  
>>>> positions
>>>> we want to borrow. Then again, maybe it's something else entirely.
>>>>
>>>> Any hints?
>>>>
>>>> Best wishes,
>>>>
>>>> baptiste
>>>>
>>>>
>>>>
>>>>
>>>> On 12 September 2010 03:27, David Winsemius<dwinsemius at comcast.net>
>>>> wrote:
>>>>>
>>>>> On Sep 11, 2010, at 9:00 PM, Peter Ehlers wrote:
>>>>>
>>>>>> On 2010-09-11 16:14, Dennis Murphy wrote:
>>>>>>>
>>>>>>> Hi Baptiste,
>>>>>>>
>>>>>>> You need to use the symbol("\nnn") concept, where nnn denotes  
>>>>>>> the octal
>>>>>>> symbol number. For<    it's 074 and for>    it's 076. This  
>>>>>>> little test
>>>>>>> seemed
>>>>>>> to
>>>>>>> work:
>>>>>>>
>>>>>>> plot(1, 1, main = expression(symbol("\074")~'x,  
>>>>>>> y'~symbol("\076")))
>>>>>>>
>>>>>>> HTH,
>>>>>>> Dennis
>>>>>>
>>>>>> It's a matter of taste, but I would use "\341" and "\361".
>>>>>> However, these are still not scalable, AFAICS.
>>>>>
>>>>> Not exactly scalable angles, but you can fake it:
>>>>>
>>>>> plot(1, 1, main = expression(symbol("\341")~scriptstyle( atop(x,y)
>>>>> )~symbol("\361")), cex.main=3)
>>>>>
>>>>> scriptstyle shrinks the inner atop() material, and since I  
>>>>> tested on a
>>>>> Mac
>>>>> it should work for Baptiste.
>>>>>
>>>>> --
>>>>> David.
>>>>>>
>>>>>>  -Peter Ehlers
>>>>>>
>>>>>>>
>>>>>>> On Sat, Sep 11, 2010 at 10:01 AM, baptiste auguie<
>>>>>>> baptiste.auguie at googlemail.com>    wrote:
>>>>>>>
>>>>>>>> What do people use to show angle brackets<    >    in R  
>>>>>>>> graphics? Have I
>>>>>>>> missed something obvious?
>>>>>>>>
>>>>>>>> Thanks,
>>>>>>>>
>>>>>>>> baptiste
>>>>>>>>
>>>>>>>> On 9 September 2010 17:57, baptiste auguie
>>>>>>>> <baptiste.auguie at googlemail.com>    wrote:
>>>>>>>>>
>>>>>>>>> Dear list,
>>>>>>>>>
>>>>>>>>> I read in ?plotmath that I can use bgroup to draw scalable  
>>>>>>>>> delimiters
>>>>>>>>> such as [ ] and ( ). The same technique fails with<    >     
>>>>>>>>> however, and
>>>>>>>>> I
>>>>>>>>> cannot find a workaround,
>>>>>>>>>
>>>>>>>>> grid.text(expression(bgroup("<",atop(x,y),">")))
>>>>>>>>>
>>>>>>>>> Error in bgroup("<", atop(x, y),">") : invalid group delimiter
>>>>>>>>>
>>>>>>>>> Regards,
>>>>>>>>>
>>>>>>>>> baptiste
>>>>>>>>>
>>>>>>>>> sessionInfo()
>>>>>>>>> R version 2.11.1 (2010-05-31)
>>>>>>>>> x86_64-apple-darwin9.8.0
>>>>>
>>>>> David Winsemius, MD
>>>>> West Hartford, CT
>>>
>>>
>>>
>>
>> ______________________________________________
>> R-help at r-project.org 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.
>
> -- 
> Dr Paul Murrell
> Department of Statistics
> The University of Auckland
> Private Bag 92019
> Auckland
> New Zealand
> 64 9 3737599 x85392
> paul at stat.auckland.ac.nz
> http://www.stat.auckland.ac.nz/~paul/



More information about the R-help mailing list