Search code examples
rpdfsvgadobe-illustratorinkscape

Why doesn't Inkscape correctly read PDF files generated by R?


Very often, I draw graphs in R and export them in pdf or svg. Then I import them in Inkskape or Illustrator. Sometimes this generates weird results. For instance, when I generate a simple scatterplot with shapes (1 and 16), Inkscape in unable to read it and generate the following file. See my gist file. I suspect that this should be due to the default options of the pdf() graphics device but I'm not sure. Does anyone has a solution?


Solution

  • This is a symptom of different fonts being used as the plotting symbols. Try creating the PDF file using:

       pdf("test.pdf", useDingbats = F) 
       plot(1:10, 10:1, pch=16 )
       dev.off()
    

    Screenshot from Inkscape Screenshot from Inkscape

    There is a long "Note" in ?pdf about why the authors of R think some pdf viewers (apparently Inkscape being one such) are failing and some configuration suggestions which I have not tested on my Mac.