I’m making some plots in R. The resulting PDFs don’t display properly on iOS devices like the iPhone. For example, here’s a stock ggplot2 figure created as a PDF:
library(ggplot2)
mpg.eg <- within(mpg[1:74,], {
model <- reorder(model, cty)
manufacturer <- reorder(manufacturer, -cty)
})
pdf(file="figures/ios-example.pdf")
p <- qplot(cty, model, data=mpg.eg)
p + facet_grid(manufacturer ~ ., scales="free", space="free") +
opts(strip.text.y = theme_text())
dev.off()
When viewed on an iPhone, the dots in the dotplot are not displayed. See, e.g., the resulting pdf if you’re on an iOS device.
I understand from reading the docs that this is most likely a problem with limited font availability and the vagaries of PDF rendering on iOS, not an issue with pdf creation in R. I had thought that maybe embedding fonts in the PDF with
embedFonts("figures/ios-example.pdf")
would sort things out, but it doesn’t. Is there something I can do to work around this iOS issue beyond just making the figure available in some other format?
embedFontsby default doesn’t embed the standard PDF font set, and therefore doesn’t actually make any significant changes to your example PDF. Try insteadand if that doesn’t work, tack "
-dPDFSETTINGS=/printer" on there too.[EDIT August 2020: With current versions of R, another thing to try is switching from the
pdfdevice to thecairo_pdfdevice.cairo_pdfuses a more sophisticated library for PDF generation and, among other things, it embeds fonts itself.]For what it’s worth, though, your example is displayed correctly on the only iOS device I have to hand (iPad, OS version 4.2.1).