Dear R-experts---is there a relatively low-pain way to get unicode characters into a plot to a pdf device? pdf(file="cardsymbols.pdf") plot( 0, xlim=c(0,5), ylim=c(0,5), type="n") text(1,1, "♠") text(2,2, "♥") text(3,3, "♦") text(4,4, "♣") dev.off() (these are the characters that I need the most NOW, but this is a more generic question.) sincerely, /iaw ---- Ivo Welch (ivo.welch at gmail.com)
On May 15, 2011, at 9:06 AM, ivo welch wrote:> Dear R-experts---is there a relatively low-pain way to get unicode > characters into a plot to a pdf device? > > pdf(file="cardsymbols.pdf") > plot( 0, xlim=c(0,5), ylim=c(0,5), type="n") > text(1,1, "♠") > text(2,2, "♥") > text(3,3, "♦") > text(4,4, "♣") > dev.off() > > (these are the characters that I need the most NOW, but this is a more > generic question.)The last examples in ?points should be reviewed and tested. It is cited by the ?plotmath page as a way of getting at symbols. -- David Winsemius, MD Heritage Laboratories West Hartford, CT
Hi: For your specific problem, one way is: plot( 0, xlim=c(0,5), ylim=c(0,5), type="n", cex = 2) text(1, 1, expression(symbol('\252'))) text(2, 2, expression(symbol('\251'))) text(3, 3, expression(symbol('\250'))) text(4, 4, expression(symbol('\247'))) More generally, David's advice is sound; see ?plotmath and focus on the sections 'Other symbols' and 'References'; the last reference provides a summary table of standard symbols and their codes in several formats. HTH, Dennis On Sun, May 15, 2011 at 6:06 AM, ivo welch <ivo.welch at gmail.com> wrote:> Dear R-experts---is there a relatively low-pain way to get unicode > characters into a plot to a pdf device? > > pdf(file="cardsymbols.pdf") > plot( 0, xlim=c(0,5), ylim=c(0,5), type="n") > text(1,1, "♠") > text(2,2, "♥") > text(3,3, "♦") > text(4,4, "♣") > dev.off() > > (these are the characters that I need the most NOW, but this is a more > generic question.) > > sincerely, /iaw > > ---- > Ivo Welch (ivo.welch at gmail.com) > > ______________________________________________ > 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. >
Dennis Murphy <djmuser <at> gmail.com> writes:> > On Sun, May 15, 2011 at 6:06 AM, ivo welch <ivo.welch <at> gmail.com> wrote: > > Dear R-experts---is there a relatively low-pain way to get unicode > > characters into a plot to a pdf device? > >[snip] I think <http://tinyurl.com/3gmlhvo> might help. Ben Bolker
On Sun, May 15, 2011 at 3:06 PM, ivo welch <ivo.welch at gmail.com> wrote:> Dear R-experts---is there a relatively low-pain way to get unicode > characters into a plot to a pdf device? >Have you tried Cairo package or cairo_pdf()? Both are making use of Cairo, which uses UTF-8 and automatically embeds fonts. Regards Liviu