[R] Forall symbol with plotmath/grid
Paul Murrell
paul at stat.auckland.ac.nz
Fri Aug 24 10:49:47 CEST 2007
Hi
Michael Hoffman wrote:
> I am trying to get the forall symbol (upside down "A") as part of the
> label of a lattice plot. Is there an easy way to do this?
It is easy enough to produce a forall on its own ...
library(grid)
grid.text("\042", gp=gpar(fontfamily="symbol"))
... but combining that with other text is trickier. One approach is to
draw separate pieces of text next to each other ...
grid.newpage()
tg <- textGrob("whatever ", just=c("left", "bottom"))
grid.draw(tg)
grid.text("\042", x=unit(.5, "npc") + grobWidth(tg),
just=c("left", "bottom"),
gp=gpar(fontfamily="symbol"))
... but that can get tedious.
A better solution is to use plotmath, but the problem there is that you
cannot access the forall symbol (even though it is in the symbol font).
I have added a feature to plotmath in the development version (to be R
2.6.0) to make it easier to get at any symbol you want. In the next
version of R, you will be able to do something like this ...
grid.newpage()
grid.text(expression("whatever "*symbol("\042")))
Paul
--
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