1

When I run ggplot() I randomly get one or both of these two errors:

Error in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : polygon edge not found

or:

HOW_BACKTRACE environmental variable.

Initially, the code does not run. But if I attempt to run that code chunk three or four more times eventually it works.

This is NOT the same error as in Error in grid.Call by user1393491, because I do not receive this portion of the error:

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"

I have tried removing the MS Arial font and enabling Arial.ttf as in the above question to no avail. However, I'm not convinced that the font error is actually the problem.

Here is one example of a gglot() script that causes this error, but the error pops up any time I call ggplot():

ggplot(n2o_ghad_sum, aes(y = mean, x = date, ymin = mean - se,
ymax = mean + se, fill = system, xmin = min(date), xmax = max(date))) +
coord_fixed(ratio = 0.2/(24/100)) +
geom_bar(aes(alpha = system), color = 'black', size = 0.2,
  stat = 'identity', position = position_dodge(width = 6.5)) +
geom_errorbar(position = position_dodge(width = 6.5)) +
scale_fill_manual(name = "System",
  labels = c("Post-Harvest\n+ Tillage","PH+T\nCC Removed",  
  "Interseeded\n(BM)", "IS (BM)\nCC Removed"),
values = c(ph_col, ph_col, us_col, us_col)) +
scale_x_date(breaks = unique(n2o_ghad_sum$date), date_labels = "%b %d") +
scale_alpha_manual(name = "System",
  labels = c("Post-Harvest\n+ Tillage","PH+T\nCC Removed",  
  "Interseeded\n(BM)", "IS (BM)\nCC Removed"),
  values = c(1, 0.3, 1, 0.3)) +
labs(x = "Date", y = expression(atop(paste('N'[2], 'O Emissions'),
  paste('(g N'[2], O-N ~ ha^{-1} ~ d^{-1}, ')'))))

Using R version 3.3.0 and ggplot2 version 2.2.1

How can I prevent this error in the future? Let me know if there's any further information that I can provide.

Andrew
  • 490
  • 3
  • 9

0 Answers0