Error in grid.Call(L_textBounds, as.graphicsAnnot(

2020-01-26 08:01发布

I just installed RStudio on Mac OS X, version 10.7.3. After executing the following commands

library(ggplot2)
qplot(mpg, wt, data=mtcars)

I get the following error:

Error in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  : 
  Polygon edge not found
In addition: Warning messages:
1: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  :
  no font could be found for family "Arial"
2: In grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  :
  no font could be found for family "Arial"

How do I fix this?

标签: r ggplot2
11条回答
何必那么认真
2楼-- · 2020-01-26 08:23

As others have cited, this issue definitely seems to be related to a Microsoft Office upgrade (my company had just upgraded the software immediately before the issue surfaced).

After attempting to run a simple ggplot2 plot, I received the following Error and Warning:

Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  : 
  polygon edge not found
Warning messages:
1: In grid.Call(C_stringMetric, as.graphicsAnnot(x$label)) :
  no font could be found for family "Arial"

I resolved this issue by performing the following actions:

(1) Open Font Book

(2) Navigate to the Arial Font

(3) Right Click -> "Restore Font"

Then the plot rendered perfectly.

I hope this helps!

查看更多
We Are One
3楼-- · 2020-01-26 08:23

I added an extra parameter to my qqplot() function like this:

theme(text=element_text(family="Garamond", size=14))

and sure enough - got a chart. End result then is:

ggplot(train, aes(x = pclass, fill = factor(survived))) +
  geom_bar() +
  xlab("Pclass") +
  ylab("Total Count") +
  labs(fill = "Survived") +
  theme(text=element_text(family="Garamond", size=14))

I did open Font Book and on my system (Mac OSX 10.12.3) is shows Arial as being off. I do have Microsoft apps installed including MS Excel but I cannot at this point correlate the disabling of any font with the install of any MS app. HTH

查看更多
Luminary・发光体
4楼-- · 2020-01-26 08:24

I resolved by going to Font Book, going to File -> Restore Standard Fonts.

查看更多
等我变得足够好
5楼-- · 2020-01-26 08:26

After a few trials, I think this "fix" could help. First try running this to ensure the fonts actually exist:

loadfonts(dev="win")

If they do, call the following to ensure the name you're calling is similar to that R knows:

windowsFonts()

Otherwise, try the following:

library(extrafont)
extrafont::font_import()

The above fixed problems for me. Hope someone in the future may be helped by the same.

查看更多
唯我独甜
6楼-- · 2020-01-26 08:33

After coming across the same problem again and again and trying different solutions I have decided to source the Arial font externally and add it to the Font Book. Prior to this exercise I had a number of fonts that came with MS Office, like Arial Black, Arial Narrow and so no but no plain Arial font visible. I'm guessing that this can be explained by the odd font policy that MS applications on Mac are applying, which is discussed in a greater detail here. Nevertheless, it appears that adding font externally solved the problem.

All Fonts

查看更多
登录 后发表回答