Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Troubleshoot: polygon edge not found

Tags:

r

Does anyone know what this error message means? I tried to change the font to Helvetica, then it worked for small data frames. However, when I try to plot large data frames the error shows up again.

I am using RStudio on Mac

> head(Merged_Columns.m)
    SYMBOL Cond variable    value
1    Baz2b    T       0h  40.5629
2     Tpm4    T       0h  44.8539
3    H2-K1    T       0h 218.9180
4    Usp22    T       0h  23.6377
5     Mreg    T       0h  95.8775
6 Arhgap30    T       0h  40.1333

p <- ggplot(Merged_Columns.m, aes(variable, value, colour=Cond)) + geom_point() 
p + theme_bw(base_family= 'Helvetica') + facet_wrap(~SYMBOL,ncol = 2) + scale_y_continuous(trans = log2_trans(),
                                                      breaks = trans_breaks("log2", function(x) 2^x),
                                                      labels = trans_format("log2", math_format(2^.x))) +
 theme(axis.text.x  = element_text(angle=90)) +
  labs(title="10 > CPM > 8", x= "Time (h)" , y= "Expression (log2)")


Error in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  : 
  polygon edge not found
like image 804
BioMan Avatar asked Nov 22 '22 01:11

BioMan


2 Answers

I can reproduce your error intermittently running your code on your small sample (RStudio on Mac 1.2.5019).

The issue might be the same as this issue, which points to some low-level bugs with displaying expressions as labels in the underlying graphics code, particularly using math_format() and superscripts. This issue has received some attention and incremental fixes from maintainers since your original post -- although it may not be 100% resolved yet.

What should you do?

  1. Ensure you're using the latest RStudio to make sure you're getting the benefit of future bug fixes.
  2. Watch out when using certain expressions to form labels in ggplot2.

It's not a solution, but if you drop the labels = ... argument entirely from your scale_y_continuous(), or choose another format, hopefully you won't receive this same error.


There is another issue regarding font availability on SO (Error in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y, : Polygon edge not found), although that error message has additional warnings and doesn't seem to be at fault in your example.

like image 158
ravic_ Avatar answered Nov 24 '22 16:11

ravic_


I had this similar issue with hrbrthemes (which build up on ggplot) and after reading the logs, I found this message:

NOTE: Either Arial Narrow or Roboto Condensed fonts are required to use these themes.
  Please use hrbrthemes::import_roboto_condensed() to install Roboto Condensed and
  if Arial Narrow is not on your system, please see ...

Ensure the specific fonts are installed, in my case hrbrthemes::import_roboto_condensed() did the trick.

like image 23
Kranja Avatar answered Nov 24 '22 14:11

Kranja