dear R wizards: is it possible to use a postscript font symbol as a plot symbol? in particular, I want to use the four postscript symbols for playing cards (club, heart, spade, diamond) as points. In LaTeX, these four are \Pisymbol{psy}{"A7} \Pisymbol{psy}{"A8} \Pisymbol{psy}{"A9} \Pisymbol{psy}{"A10} and what I would love to do is place them, at say, (x=1,y=1), (x=2,y=2), (x=3,y=3) and (x=4,y=4). Help appreciated---or merely a note that this is impossible. regards, /iaw --- ivo welch
On Tue, 2005-02-01 at 18:48 -0800, ivo_welch-rstat8303 at mailblocks.com wrote:> dear R wizards: > > is it possible to use a postscript font symbol as a plot symbol? in > particular, I want to use the four postscript symbols for playing cards > (club, heart, spade, diamond) as points. In LaTeX, these four are > > \Pisymbol{psy}{"A7} \Pisymbol{psy}{"A8} > \Pisymbol{psy}{"A9} \Pisymbol{psy}{"A10} > > and what I would love to do is place them, at say, (x=1,y=1), > (x=2,y=2), (x=3,y=3) and (x=4,y=4). Help appreciated---or merely a > note that this is impossible.Ivo, This may not be exactly what you want, but... Using the Hershey vector fonts, you can plot (using text()) a variety of symbols. See ?Hershey and demo(Hershey) for more information. Here is an example: plot(0:5, 0:5, type = "n") text(1:4, 1:4, vfont = c("sans serif", "plain"), labels = c("\\CL", "\\DI", "\\HE", "\\SP"), cex = 2) The set of escaped characters in the vector for the 'labels' argument are the codes for clubs, diamonds, hearts and spades, respectively. HTH, Marc Schwartz
On Tue, 1 Feb 2005, Marc Schwartz wrote:> On Tue, 2005-02-01 at 18:48 -0800, ivo_welch-rstat8303 at mailblocks.com > wrote: >> dear R wizards: >> >> is it possible to use a postscript font symbol as a plot symbol? in >> particular, I want to use the four postscript symbols for playing cards >> (club, heart, spade, diamond) as points. In LaTeX, these four are >> >> \Pisymbol{psy}{"A7} \Pisymbol{psy}{"A8} >> \Pisymbol{psy}{"A9} \Pisymbol{psy}{"A10} >> >> and what I would love to do is place them, at say, (x=1,y=1), >> (x=2,y=2), (x=3,y=3) and (x=4,y=4). Help appreciated---or merely a >> note that this is impossible.Font 5 is the symbol font, so plot(1:5, type="n") points(1:4, 1:4, pch=167:170, font=5) does this (not in that order, but you can make the mapping from that plot). -- Brian D. Ripley, ripley at stats.ox.ac.uk Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UK Fax: +44 1865 272595
A propos of these symbols, Henrik Bengtsson (Lund University, Sweden) posted to this list some time ago a very useful function ``plotSymbols'', which can be slightly modified as follows: plotSymbols <- function (fn=1) { i <- 0:255 ncol <- 16 opar <- par(cex.axis = 0.7, mar = c(3, 3, 3, 3) + 0.1) plot(i%%ncol, 1 + i%/%ncol, pch=i, font=fn, xlab = "", ylab = "", axes = FALSE) axis(1, at = 0:15) axis(2, at = 1:16, labels = 0:15 * 16, las = 2) axis(3, at = 0:15) axis(4, at = 1:16, labels = 0:15 * 16 + 15, las = 2) par(opar) } You can use this function to see what you get under various font specifications. Of course it would help to know a priori that font number 5 gave you the postscript symbols! cheers, Rolf Turner rolf at math.unb.ca