Graphics Problem: Export from R to PDF, Import to Inkscape

Post questions on how to use or achieve an effect in Inkscape.
Adam Carr
Posts: 2
Joined: Fri Dec 31, 2010 3:29 am

Graphics Problem: Export from R to PDF, Import to Inkscape

Postby Adam Carr » Fri Dec 31, 2010 4:10 am

Good Afternoon:

I am rather new to Inkscape but I have enjoyed learning the software. I think it is very powerful and elegant, but I also know that I have much to learn.

I am running Inkscape 0.48 on a Windows XP machine with the following system details:

OS Name Microsoft Windows XP Professional
Version 5.1.2600 Service Pack 3 Build 2600
System Type X86-based PC
Processor x86 Family 6 Model 15 Stepping 11 GenuineIntel ~1995 Mhz
BIOS Version/Date LENOVO 7LETB7WW (2.17 ), 4/25/2008
Total Physical Memory 4,096.00 MB
Available Physical Memory 1.62 GB
Total Virtual Memory 2.00 GB
Available Virtual Memory 1.96 GB
Page File Space 8.69 GB

I am putting together a large report with plots created in statistical software package R, V 2.12.0. Most of the plots are created using add-on package ggplot2 V0.8.9. I use R's pdf() command to export the plot to a pdf file. Oddly enough, the reason I am using Inkscape in this case is to simply edit the title text because ggplot2 does not support superscript or subscript in the title text. For the report I am working on these formats are essential. A user in the R-help community suggested I use Inkscape to quickly edit the font and export the plot for use in my report.

I have attached an R-exported pdf file exactly as it looks as opened in Adobe Reader V9. This file is named exportforinkscapeforum.pdf

The problem I have is that when I import the pdf into Inkscape the solid, filled circles on the plot are converted to the lower case letter q. I read about similar problems on R-help.org and other R-related sites, but the descriptions I found seemed to indicate that the lower case q was visible in the pdf file when opened with Adobe or other viewers. This does not seem to be my problem. I have also attached an example of the way the plot appears after I import it into Inkscape.

I apologize if I overlooked this issue on the Inkscape forum. I did search for the problem but it appeared that most of the issues I located were related to font interpretation by Inkscape.

Any help would be appreciated.

Adam
Attachments
exportforinkscapeforum.pdf
Exported directly from R using pdf()
(34.54 KiB) Downloaded 239 times
Example of How Imported PDF Looks in Inkscape.pdf
(94.96 KiB) Downloaded 252 times

~suv
Posts: 2272
Joined: Sun May 10, 2009 2:07 am

Re: Graphics Problem: Export from R to PDF, Import to Inksca

Postby ~suv » Fri Dec 31, 2010 6:52 am

I don't have a workaround (nor - admittedly - downloaded and looked at your attached files yet), but AFAICT it was reported in Inkscape's bug tracker [1] too. Those "solid, filled circles on the plot" are not filled circles (or paths) but special glyphs (i.e. actually text objects) using a dingbat or symbol font and expose known font substitution issues when importing a PDF in Inkscape.

Is there any way you could influence the export from R to use paths or actual dots/circles for denoting points in the plotted graph?

[1] Bug #668701 in Inkscape: “artefacts in pdf from R with ghostscript

[Edit] Here's a screenshot how the file looks when opened in Inkscape (0.48+devel r9994) on OS X 10.5.8: the font for the points is 'Zapf Dingbat' (I haven't investigated if Inkscape substitutes it or if the same font is defined and embedded in the PDF file).
screenshot-osx-1.png
screenshot-osx-1.png (77.06 KiB) Viewed 4693 times
It is known that symbol fonts have platform- (or font-end) related issues in Inkscape (most dingbat fonts fail to even load in the Windows port of Inkscape)
[/Edit]

Adam Carr
Posts: 2
Joined: Fri Dec 31, 2010 3:29 am

Re: Graphics Problem: Export from R to PDF, Import to Inksca

Postby Adam Carr » Fri Dec 31, 2010 8:37 am

Thanks very much for the reply. I see the Zapf Dingbat font embedded in the PDF. I have no idea if this kind of symbol interpretation can be influenced by a command in R but I will investigate via a post on R-help. I am disappointed. It seems that the other graphics export formats from R such as SVG, JPEG, bitmap, and others, either have their own complications or cannot be used to edit text. Amazing how such a seemingly minor issue becomes anything but minor very quickly.

Adam

brettmontgomery
Posts: 1
Joined: Sun Sep 25, 2011 3:09 pm

Re: Graphics Problem: Export from R to PDF, Import to Inksca

Postby brettmontgomery » Sun Sep 25, 2011 3:22 pm

This reply is a bit slow, so I hope you've already found an answer to this question. However, in case you haven't, or for the benefit of other people faced with the same issue, here goes.

You can indeed change the output from R to use actual circles rather than the Dingbats font circles. Simply include the argument "useDingbats=FALSE" when using the pdf() command in R.

For example:

Code: Select all

pdf(file = "example.pdf", useDingbats=FALSE)


See the documentation of the R PDF graphics device: http://stat.ethz.ch/R-manual/R-devel/library/grDevices/html/pdf.html

ucfagls
Posts: 1
Joined: Fri Dec 02, 2011 8:01 pm

Re: Graphics Problem: Export from R to PDF, Import to Inksca

Postby ucfagls » Fri Dec 02, 2011 8:05 pm

An alternative solution is to plot on an svg device, which is now a native device in R - from at least R 2.14.0 but possibly in the previous version also - which imports nicely in Inkscape. See ?svg for details.


Return to “Help with using Inkscape”