ggplot2 pdf import in Adobe Illustrator missing font AdobePiStd
Asked Answered
E

9

55

I created several simple ggplot2 plots and saved them to PDF files using the following commands:

p <- ggplot(plotobject, aes(x=Pos, y=Pval),res=300)
ggsave(plot=p,height=6,width=6,dpi=200, filename="~/example.pdf")

If I now open this example.pdf in Adobe Illustrator I get the following error:

The font AdobePiStd is missing. Affected text will be displayed using a substitute font.

Is there a way in ggplot2 to specify a font (I presume this is for the dots/points) that Adobe will understand or otherwise is there a way to get this font working in Adobe?

/edit just to clarify, the text/labels/titles are all just fine its the dots that are missing for the font /edit2 I got a working solution by just using the EPS output in ggsave, but still would love to find out a way to also be able to just open/import ggplot2 plots in PDF format directly in AI

Emlynn answered 3/4, 2012 at 11:25 Comment(4)
I have the same problem. By opening a ggplot pdf file in a text editor, I was able to see that ggplot2 specifies Zapf Dingbats as the symbol font. So why does AI try to use AdobePiStd (missing) instead of Zapf Dingbats (present)? I don't know, but I suspect changing the font that ggplot2 specifies will not solve the problem. I solved this by copying the font file /Library/Application Support/Adobe/PDFL/8.0/Fonts/AdobePiStd.otf from my mac to my colleague's Win7 machine (drag onto font control panel to install).Martyrology
@Martyrology so if I do this I can actually just open PDFs directly without any complaints?Emlynn
Yes. Plotting symbols in pdfs now appear correctly with no further action. @Jim M.'s solution is more general (but must be done for each file).Martyrology
@bdemarest: Thats actually the best and most convenient way to solve this, thank a lot! I found the font on my machine in C:\Program Files (x86)\Adobe\Acrobat 10.0\Resource\Font, as I have bought the student version of the Adobe Creative Suite with Acrobat X Pro included. I just copied the font to the windows fonts directory, and now I can load the plots without any complaints!Eloquent
B
58

Although changing the fonts used by AI works well, an alternative is to restrict ggplot2 from using Dingbats in the first place by adding the argument 'useDingbats' to your ggsave command eg:

ggsave(plot=p,height=6,width=6,dpi=200, filename="~/example.pdf", useDingbats=FALSE)
Babur answered 13/2, 2014 at 14:11 Comment(5)
This is brilliant! Thank you so much, I've been looking for this for years.Pyxie
Because the 2nd most upvoted answer might suggest this doesn't work on modern macs, I'm commenting to say using the useDingbats=FALSE works for me using Mac OS X 10.13.5 and Adobe Illustrator 22.0.0.Bartholomeus
useDingbats=FALSE also works if AI displays your geom_point dots as squares.Crankpin
Would like to add that this also works for tmap_save() from the mapping package tmapKape
my life is significantly improved because of thisMaximinamaximize
M
37

I ran into this problem as well on Mac OS X 10.8.2.

This resolved the issue for me:

font='/Library/Application Support/Adobe/PDFL/10.9/Fonts/AdobePiStd.otf'
cp $font /Library/Fonts/

On your system, find the file with find:

find / -name AdobePiStd.otf 2>/dev/null

/Applications/Adobe Photoshop CC 2018/Adobe Photoshop CC 2018.app/Contents/Required/PDFL/Resource/Fonts/AdobePiStd.otf
/Applications/Adobe Illustrator CC 2018/Adobe Illustrator.app/Contents/Required/PDFL Resource/Resource/Fonts/AdobePiStd.otf
/Applications/Adobe Acrobat DC/Adobe Acrobat.app/Contents/Resources/Resource/Font/AdobePiStd.otf
Mythologize answered 19/2, 2013 at 19:58 Comment(3)
Of the 5 (current) answers to this question, this was the only one I was able to successfully implement.Neoclassicism
just tested this and works flawless. Though other answers work this is clearly the best one.Emlynn
On Windows 7 find the otf files in C:\Program Files (x86)\Adobe\Reader 10.0\Resource\Font\ and use right-click > Install. (The version of the Reader may vary of course...)Modality
N
10

For dots or points that don't' display correctly in a pdf, I just substitute Zapf Dingbats for the missing font in Adobe Illustrator. For simple plot markers, this does the job most of the time.

Nighthawk answered 3/4, 2012 at 13:36 Comment(2)
I'm still quite a newbee in AI, so how would I do this? AI just raise this error when I import the PDF and then replace them automatically with squares. Are the datapoints still at the exact same place after doing this? I've read somewhere on the R mailinglist (can't find the thread 123) that people complained that this made their datapoints slightly shifting positions, something I would be not too happy with.Emlynn
@Emlynn In AI (I'm using CS4 for Mac), under the Type menu, there should be a Find Font menu item. In the dialog box, you highlight the AdobePiStd in the upper box, and select Zapf Dingbats in the lower box once you pull down the Replace Font from "System" to show available fonts. There might be some minor shifting, but this may be negligible depending on your axis scales.Nighthawk
G
9

This seems to be a perverse problem in which Adobe Illustrator cannot find a font (AdobePiStd) that is distributed with Adobe Reader and thus is likely present.

If you search your computer, you are likely to find it. On my WindowsXP system, it was in: C:\Program Files\Adobe\Reader 10.0\Resource\Font

After finding it, you can install it and other fonts in that folder, which should enable Illustrator to find them.

For other font/pdf problems in R, the embedFonts function in grDevices package is useful.

Glean answered 5/11, 2012 at 19:21 Comment(1)
In addition to embedFonts, there is now an extrafont package that makes it easier to embed fonts in ggplotGlean
O
9

Use useDingbats=FALSE for the pdf output, then Illustrator will no complain.

pdf("example.pdf", useDingbats=FALSE)
ggplot(plotobject, aes(x=Pos, y=Pval),res=300)
dev.off()
Ogee answered 9/3, 2014 at 19:53 Comment(1)
I think this is the smartest suggestion, as this will ensure the same R script works on different machines (with or without PiStd present in the right path).Snag
S
4

EDIT 2018 The question under was for the initial confusion face. The answer to this question is pdf(useDingbats = FALSE) as stated in numerous answers above. I won't delete this answer, in case you want to read about fonts (which might become a problem too).

OLD ANSWER AI does not recognize Helvetica type fonts. In my computer it doesn't matter that much, since it automatically replaces the font with something suitable. Of course you'd want to change the font in some cases. I often do it manually in AI (just select all the text and change the font type). Here is a thread on how to change the font in ggplot2: Modifying fonts in ggplot2

Ps. There is also another thread that might be helpful: Fonts in R plots

Soluble answered 3/4, 2012 at 12:26 Comment(1)
Thanks for the suggestion, updated the question. The text of labels and titles is not the issue it are the data points themselves that are missing font wise.Emlynn
S
3

You can download the font AdobePiStd - just Google it, download and install. After you reboot, the font should display correctly. You can then use the 'Find Font ...' utility within Illustrator to change it if you wish.

Safekeeping answered 14/1, 2013 at 2:5 Comment(0)
A
0

Another option that in simple cases might solve the problem is to in illustrator select the textobjects not displayed correctly and change the font. Helvetica Neue works for me.

Argive answered 17/8, 2017 at 14:53 Comment(0)
C
0

I could solve the problem just by adding alpha specification. If you don't need any transparency you can chose an alpha value of 0.9 ...

example:

ggplot() + geom_point(aes(x=..,y=.., color=...), alpha=0.8)
Comer answered 30/7, 2019 at 16:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.