The “p” problem in R plots, or when a dot is a font in inkscape

My graphics/figure workflow generally involves plotting something in R, saving it as a pdf (+png if writing a report with Rmarkdown), followed by some manual editing with Inkscape. Inkscape is a free, as in speech and beer, vector graphics editor – think of a non-commercial Illustrator – and it has very very useful since most of the time I don’t have access to Illustrator, through a combination of working mostly in Linux and the groups not paying for a license. No matter as Inkscape serves me well, including for personal use.

Problem

Back to the science. There is a quick with R plots: by default plots save symbols as fonts dingbats font. This means that when opening a pdf created with R in Inkscape (or Illustrator), points are (correctly) displayed as “p”. Even though this is technically correct, it is a nightmare when editing a figure last minute before a presentation.

Solution

Set set the option r useDingbats = FALSE when saving the plot:

dat <- sample(1:1000,100)
plot(dat)
pdf("plot.pdf", useDingbats = FALSE)
plot(dat)
dev.off()

Or even better, make use of Rprofile for more than witty R quotes, adding to it the line grDevices::pdf.optionspdf.options(useDingbats = FALSE). Like this, you will not have to remember this every time a plot is saved. And if you are like me, this will happen often – both the saving and the forgetting.

Source1
Source2

Advertisements
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s