[R] expressions on graphs

Ben Bolker ben at zoo.ufl.edu
Tue Apr 9 21:18:29 CEST 2002


 This came up a bit earlier on the r-help list, and I hacked on it some
with Paul Murrell's help.  The short answer is that there is no dot in
plotmath (and it is now feature-frozen out of 1.5.0), but it's not too
hard to hack.

  If you're up to it and want it badly enough you can probably piece
together a solution from what's included below; otherwise, if you ask I
can send you a modified plotmath.c to re-compile with.

  Ben


---------------
>From p.murrell at auckland.ac.nz Tue Apr  9 15:15:28 2002
Date: Tue, 5 Mar 2002 14:59:48 +1300
From: Paul Murrell <p.murrell at auckland.ac.nz>
To: bolker at zoo.ufl.edu
Cc: tobias.hoevekamp at ilw.agrl.ethz.ch
Subject: Re: [R] R-plots with 'complex' axis-labelling

Hi


>   Here's what I've got so far -- trivially easy to get this far but I'm
> not sure where to go from here.  The change is effectively a one-line
> change in plotmath.c, although I've complicated it slightly for testing
> purposes:
>
> *** /usr/local/src/R/R-1.4.1/src/main/plotmath.c.orig Fri Mar  1 10:05:01
2002
> --- /usr/local/src/R/R-1.4.1/src/main/plotmath.c Fri Mar  1 13:56:30 2002
> ***************
> *** 1600,1605 ****
> --- 1600,1610 ----
>       { "hat", 94 },
>       { "ring", 176 },
>       { "tilde", 126 },
> +     { "dot1",            46 },  /* period (46) is too small */
> +     { "dot2",           215 },
> +     { "dot3",           183 },
> +                        /* 215 produces an x instead of "dotmath"? */
> +                                 /* 183 is square */
>       { NULL,   0 },
>   };


Thanks Ben.
If you make the following additional changes, the "dotmath" symbol will work
(it is a character in the symbol font).

1642c1647,1650
<     accentBBox = RenderChar(code, 0);
---
>     if (code == 215) /* dotmath */
>       accentBBox = RenderSymbolChar(code, 0);
>     else
>       accentBBox = RenderChar(code, 0);
1655c1663,1666
<       RenderChar(code, draw);
---
>       if (code == 215) /* dotmath */
>           RenderSymbolChar(code, draw);
>       else
>           RenderChar(code, draw);



> postscript("test.ps",family="Times")
> plot(c(0,1),c(0,1),type="n")
> text(0.2,0.2,expression(dot1(a)))
> text(0.3,0.3,expression(dot2(b)))
> text(0.4,0.4,expression(dot3(c)))
> text(0.5,0.5,expression(a.b))
> par(cex=3)
> text(0.6,0.6,expression(dot1(a)))
> text(0.7,0.7,expression(dot2(b)))
> text(0.8,0.8,expression(dot3(c)))
> text(0.9,0.9,expression(a.b))
> dev.off()
>
> Results vary slightly depending on what font you use -- in Helvetica all
> dots come out square and bullet/period spacing looks slightly different,
> in Palatino and Times they're round and apparently equivalent.  "dotmath"
> seems to come out as an x in every font.


With the dotmath change, this symbol always comes out round.  Perhaps we
could offer both a dot() and a dotmath() expression if we were able to
choose between dot1() and dot3() for our dot()?


>   So, if one were satisfied with the spacing etc. this could probably work
> as is.


I guess it needs someone who wants to use these dots to tell us whether this
approach is acceptable.  Does it look ok to you Tobias?  Would you prefer
some postscript files to see the examples?

Paul




On Tue, 9 Apr 2002, John Janmaat wrote:

> Hello,
>
> I am trying to get a time derivative on a plot title.  I prefer to have
> it in the form \dot{s_i}, but \partial s_i/\partial t would be O.K.  In
> the graphics demo I cannot find either a dot or a partial equivalent.
>
> Thanks,
>
> John.
>

-- 
318 Carr Hall                                bolker at zoo.ufl.edu
Zoology Department, University of Florida    http://www.zoo.ufl.edu/bolker
Box 118525                                   (ph)  352-392-5697
Gainesville, FL 32611-8525                   (fax) 352-392-3704

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list