2

Recently all my ggplot2 code has stopped working on my MacOS Monterrey v12.6.3. For example, creating a very simple plot:

library(ggplot2)

x = 1:10
y = 1:10
df = data.frame(x, y)

ggplot(df, aes(x = x, y = y)) + 
  geom_point()

I get the following error message:

Error in grid.Call(C_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  : 
  polygon edge not found
In addition: There were 50 or more warnings (use warnings() to see the first 50)

And the following warnings:

> warnings()
Warning messages:
1: In grid.Call(C_stringMetric, as.graphicsAnnot(x$label)) :
  no font could be found for family "Arial"

It seems like something is messing with the search for fonts, but I don't understand what has happened. Re-installations of ggplot2 have not resolved the problem.

This post appears to have the same problem: Error in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : Polygon edge not found

But I don't have the directories involved in the highest-voted solution, so the answer did not help me.

What is the cause of this issue? And how can I fix it?

EDIT

Additional information was requested in the comments:

> ggplot2::theme_get()$text
List of 11
 $ family       : chr ""
 $ face         : chr "plain"
 $ colour       : chr "black"
 $ size         : num 11
 $ hjust        : num 0.5
 $ vjust        : num 0.5
 $ angle        : num 0
 $ lineheight   : num 0.9
 $ margin       : 'margin' num [1:4] 0points 0points 0points 0points
  ..- attr(*, "unit")= int 8
 $ debug        : logi FALSE
 $ inherit.blank: logi TRUE
 - attr(*, "class")= chr [1:2] "element_text" "element"

> X11Fonts()
$serif
[1] "-*-times-%s-%s-*-*-%d-*-*-*-*-*-*-*"

$sans
[1] "-*-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*"

$mono
[1] "-*-courier-%s-%s-*-*-%d-*-*-*-*-*-*-*"

$Times
[1] "-adobe-times-%s-%s-*-*-%d-*-*-*-*-*-*-*"

$Helvetica
[1] "-adobe-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*"

$CyrTimes
[1] "-cronyx-times-%s-%s-*-*-%d-*-*-*-*-*-*-*"

$CyrHelvetica
[1] "-cronyx-helvetica-%s-%s-*-*-%d-*-*-*-*-*-*-*"

$Arial
[1] "-monotype-arial-%s-%s-*-*-%d-*-*-*-*-*-*-*"

$Mincho
[1] "-*-mincho-%s-%s-*-*-%d-*-*-*-*-*-*-*"

> systemfonts::font_info()
# A tibble: 1 × 24
  path    index family style italic bold  monos…¹ weight width kerning color scala…² verti…³ n_gly…⁴ n_sizes n_cha…⁵ bbox 
  <chr>   <int> <chr>  <chr> <lgl>  <lgl> <lgl>   <ord>  <ord> <lgl>   <lgl> <lgl>   <lgl>     <int>   <int>   <int> <lis>
1 /Syste…     0 Helve… Regu… FALSE  FALSE FALSE   normal norm… FALSE   FALSE TRUE    FALSE      2252       0      10 <dbl>
# … with 7 more variables: max_ascend <dbl>, max_descend <dbl>, max_advance_width <dbl>, max_advance_height <dbl>,
#   lineheight <dbl>, underline_pos <dbl>, underline_size <dbl>, and abbreviated variable names ¹​monospace, ²​scalable,
#   ³​vertical, ⁴​n_glyphs, ⁵​n_charmaps
# ℹ Use `colnames()` to see all variable names
SamPassmore
  • 1,221
  • 1
  • 12
  • 32
  • Does this answer your question? https://stackoverflow.com/questions/71362738/r-error-in-grid-callc-textbounds-as-graphicsannotxlabel-xx-xy-polygo/71363854#71363854 – jared_mamrot Mar 17 '23 at 04:23
  • No. It's strange because in `fonts()` I can see that Arial is available as a font. But I get the same error / warning. – SamPassmore Mar 17 '23 at 04:48
  • 1
    Might help to include the output of `ggplot2::theme_get()$text`, `X11Fonts()` and `systemfonts::font_info()` in your question – jared_mamrot Mar 17 '23 at 05:09
  • I have added this information. Does the systemfonts output point to something wrong with system fonts? Seems like there should be more lines in that table. – SamPassmore Mar 17 '23 at 05:30

1 Answers1

0

In the end, this problem was resolved when I upgraded my MacOS software to Ventura 13.3 (22E252). I am not sure what changed in the upgrade, but it did fix the problem.

SamPassmore
  • 1,221
  • 1
  • 12
  • 32