Multiple font families in ggsave

129 views
Skip to first unread message

Ravina, Mark

unread,
Mar 12, 2014, 1:50:00 PM3/12/14
to ggplot2
I need to use multiple font families in a single graph and save the output as a pdf. 

Kohske’s code (adapted below) is great for a single Japanese font family, but the Japanese font won’t map the Unicode character  “ō” and generates the warning 

In grid.Call.graphics(L_text, as.graphicsAnnot(x$label), x$x, x$y,  :
  failed in text conversion to encoding 'EUC-JP’

How do I keep the default font of ggplot (I’m quite pleased with that output) but add a Japanese font family? CairoPDF seems to have parallel problems.

d <- data.frame(x=1:2, y=1:2, t=c("あ","ō"))
a <- ggplot(d, aes(x, y, label=t)) + geom_text() + ggtitle("う")
ggsave("out.pdf", a, family="Japan1GothicBBB”)

Mark Ravina
Prof of History
Emory University



This e-mail message (including any attachments) is for the sole use of
the intended recipient(s) and may contain confidential and privileged
information. If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination, distribution
or copying of this message (including any attachments) is strictly
prohibited.

If you have received this message in error, please contact
the sender by reply e-mail message and destroy all copies of the
original message (including attachments).

Doug Mitarotonda

unread,
Mar 12, 2014, 2:46:32 PM3/12/14
to Ravina, Mark, ggplot2
I can't speak to your specific issue, but Winston Chang's extrafont package seems like a good place to start. Here is a blog post he did that discusses it: http://blog.revolutionanalytics.com/2012/09/how-to-use-your-favorite-fonts-in-r-charts.html


--
--
You received this message because you are subscribed to the ggplot2 mailing list.
Please provide a reproducible example: https://github.com/hadley/devtools/wiki/Reproducibility
 
To post: email ggp...@googlegroups.com
To unsubscribe: email ggplot2+u...@googlegroups.com
More options: http://groups.google.com/group/ggplot2

---
You received this message because you are subscribed to the Google Groups "ggplot2" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ggplot2+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages