Polygon edge not found

1,386 views
Skip to first unread message

Jason Rupert

unread,
May 14, 2009, 6:01:17 PM5/14/09
to ggp...@googlegroups.com

What is the best way to look into the following error?
"Polygon edge not found"

I think it is due to something I am sending into qplot improperly, so is there something I can do at a high level to identify the problem?

I did a traceback(), but nothing stuck out.

Thanks for any information you can provide.

Here is the actual error:
Error in grid.Call("L_textBounds", as.graphicsAnnot(x$label), x$x, x$y, :
Polygon edge not found

Here is the actual call:
print(qplot(AgeBand, Frequency, data = counts, fill = AgeBand, geom = "bar", stat = "identity", width = 0.9, xlab = x_axis_title) +
facet_grid(. ~ Bin) +
opts(axis.text.x = theme_text(angle = 45, hjust = 1, colour = "grey60")) +
facet_wrap(~Bin, drop = FALSE, nrow = 1) +
opts(title = short_title) +
opts(strip.text.x = theme_text(size = fontsize_val[pp])) +
scale_fill_manual(values = c("royalblue2", "tomato3", "palegreen2")) +
opts(legend.position = c(legend_x_location[pp], 0.7)) +
opts(axis.text.x = NULL))

Here is the value of counts:
counts
Bin AgeBand Frequency
1 (-0.0242,-0.0193] Less than 1
2 (-0.0145,-0.00967] Less than 39
3 (-0.00967,-0.00483] Less than 59
4 (-0.00483,0] Less than 699
5 (0,0.00484] Less than 70
6 (0.00484,0.00967] Less than 160
7 (0.00967,0.0145] Less than 86
8 (0.0145,0.0193] Less than 13
9 (0.0193,0.0242] Less than 6
10 (0.0242,0.029] Less than 3
11 (0.0435,0.0484] Less than 1
12 (0.0484,0.0532] Less than 2
13 (0.0532,0.058] Less than 27
14 (0.058,0.0629] Less than 17
15 (0.0822,0.087] Less than 1
16 (-0.00967,-0.00483] Between 3
17 (-0.00483,0] Between 27
18 (0,0.00484] Between 3
19 (0.00484,0.00967] Between 3
20 (-0.00967,-0.00483] Greater than 4
21 (-0.00483,0] Greater than 82
22 (0,0.00484] Greater than 7
23 (0.00484,0.00967] Greater than 12
24 (0.00967,0.0145] Greater than 3



Jason Rupert

unread,
May 15, 2009, 10:16:26 AM5/15/09
to ggp...@googlegroups.com

Still hitting this problem -

grid.Call("L_textBounds", as.graphicsAnnot(x$label), x$x, x$y, :
Polygon edge not found


Here is the whole traceback():

26: .Call(fnname, ..., PACKAGE = "grid")
25: grid.Call("L_textBounds", as.graphicsAnnot(x$label), x$x, x$y,
resolveHJust(x$just, x$hjust), resolveVJust(x$just, x$vjust),
x$rot, 0)
24: heightDetails.text(x)
23: heightDetails(x)
22: function (x)
{
heightDetails(x)
}(list(label = "(-115,-102]", x = 0.5, y = 0.5, just = "centre",
hjust = 0.5, vjust = 0.5, rot = 0, check.overlap = FALSE,
name = "strip.text.x.text.26563", gp = list(fontsize = NA_real_,
col = "black", fontfamily = "", fontface = "plain", lineheight = 1.1,
font = 1L), vp = NULL))
21: .Call(fnname, ..., PACKAGE = "grid")
20: grid.Call("L_convert", x, as.integer(whatfrom), as.integer(whatto),
valid.units(unitTo))
19: convertUnit(x, unitTo, "y", "dimension", "y", "dimension", valueOnly = valueOnly)
18: convertHeight(strips_height, "cm")
17: inherits(unit, "unit")
16: is.unit(heights)
15: grobGrid("strip", strips, nrow = nrow, ncol = ncol, heights = convertHeight(strips_height,
"cm"), widths = 1, as.table = .$as.table)
14: get("add_guides", env = pieces$facet, inherits = TRUE)(pieces$facet,
...)
13: pieces$facet$add_guides(plot$data, pieces$panels, pieces$cs,
theme)
12: panelGrob(plot, pieces)
11: ggplotGrob(x, ...)
10: grid.draw(ggplotGrob(x, ...))
9: print.ggplot(qplot(AgeBand, Frequency, data = counts, fill = AgeBand,
geom = "bar", stat = "identity", width = 0.9, xlab = x_axis_title) +
facet_grid(. ~ Bin) + opts(axis.text.x = theme_text(angle = 45,
hjust = 1, colour = "grey60")) + facet_wrap(~Bin, drop = FALSE,
nrow = 1) + opts(title = short_title) + opts(strip.text.x = theme_text(size = fontsize_val[pp])) +
scale_fill_manual(values = c("royalblue2", "tomato3", "palegreen2")) +
opts(legend.position = c(legend_x_location[pp], 0.7)) + opts(axis.text.x = NULL))
8: print(qplot(AgeBand, Frequency, data = counts, fill = AgeBand,
geom = "bar", stat = "identity", width = 0.9, xlab = x_axis_title) +
facet_grid(. ~ Bin) + opts(axis.text.x = theme_text(angle = 45,
hjust = 1, colour = "grey60")) + facet_wrap(~Bin, drop = FALSE,
nrow = 1) + opts(title = short_title) + opts(strip.text.x = theme_text(size = fontsize_val[pp])) +
scale_fill_manual(values = c("royalblue2", "tomato3", "palegreen2")) +
opts(legend.position = c(legend_x_location[pp], 0.7)) + opts(axis.text.x = NULL))
7: print(qplot(AgeBand, Frequency, data = counts, fill = AgeBand,
geom = "bar", stat = "identity", width = 0.9, xlab = x_axis_title) +
facet_grid(. ~ Bin) + opts(axis.text.x = theme_text(angle = 45,
hjust = 1, colour = "grey60")) + facet_wrap(~Bin, drop = FALSE,
nrow = 1) + opts(title = short_title) + opts(strip.text.x = theme_text(size = fontsize_val[pp])) +
scale_fill_manual(values = c("royalblue2", "tomato3", "palegreen2")) +
opts(legend.position = c(legend_x_location[pp], 0.7)) + opts(axis.text.x = NULL))


Thanks again for any insights and feedback.


--- On Thu, 5/14/09, Jason Rupert <jasonk...@yahoo.com> wrote:

hadley wickham

unread,
May 15, 2009, 1:49:19 PM5/15/09
to Jason Rupert, ggp...@googlegroups.com
Hi Jason,

Could you please send a reproducible example?
http://ggplot2.wik.is/Creating_a_reproducible_example. It's much
easier for me to debug if I can copy and paste directly from your
email with out having to recreate your data.

Hadley
--
http://had.co.nz/

camackay

unread,
Feb 3, 2014, 2:35:29 PM2/3/14
to ggp...@googlegroups.com, Jason Rupert
Hi Hadley,

I know that this thread ended a while ago but I just came upon this problem and none of the other threads have helped.
The problems started today when I updated to the newest versions of R and ggplot2. I've tried dealing with all the font issues and creating a new user on my computer with a fresh copy of R to see if it was something on my account but it still didn't work. I've narrowed it down to my simplest problem:

qplot(data=mtcars, mpg, wt) works just fine and I get the expected result but as soon as I try to add any aesthetics, such as

qplot(data=mtcars, mpg, wt, colour=cyl)

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

Any help would be appreciated.

Dennis Murphy

unread,
Feb 3, 2014, 7:19:14 PM2/3/14
to camackay, ggplot2
I have the latest *CRAN-released* versions of R and ggplot2 on my Win7
system and your code works fine on it. What is your sessionInfo()?

> sessionInfo()
R version 3.0.2 (2013-09-25)
Platform: x86_64-w64-mingw32/x64 (64-bit)

locale:
[1] LC_COLLATE=English_United States.1252
[2] LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C
[5] LC_TIME=English_United States.1252

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] ggplot2_0.9.3.1

loaded via a namespace (and not attached):
[1] colorspace_1.2-4 dichromat_2.0-0 digest_0.6.4 grid_3.0.2
[5] gtable_0.1.2 labeling_0.2 MASS_7.3-29 munsell_0.4.2
[9] plyr_1.8 proto_0.3-10 RColorBrewer_1.0-5 reshape2_1.2.2
[13] scales_0.2.3 stringr_0.6.2

If you're using a development version of either R or ggplot2, you
should probably file it as an issue at
https://github.com/hadley/ggplot2/issues
If you are using release versions of both, you probably want to check
the following:
- are you using any packages whose functions mask those in ggplot2?
- do you have something in .Rprofile that is causing problems,
such as obsolete paths or package loads that conflict with ggplot2?
- have you looked at traceback() after the error to see if it is
informative in any way?
There may be other reasons that escape me at the moment...

Hadley has coded up a lot of unit tests in the past few years to avoid
the repetition of old bugs. You're responding to a nearly
five-year-old post, so it's highly probable that the original bug has
been fixed. It's unlikely that a qplot() call that simple would have
gone unnoticed in the release version of ggplot2 (0.9.3) in the course
of a year, but it would be more plausible in a recent development
version of either R or ggplot2...which is why the sessionInfo(), and
some more detective work on your part, is informative.

Dennis
> --
> --
> You received this message because you are subscribed to the ggplot2 mailing
> list.
> Please provide a reproducible example:
> https://github.com/hadley/devtools/wiki/Reproducibility
>
> To post: email ggp...@googlegroups.com
> To unsubscribe: email ggplot2+u...@googlegroups.com
> More options: http://groups.google.com/group/ggplot2
>
> ---
> You received this message because you are subscribed to the Google Groups
> "ggplot2" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ggplot2+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

camackay

unread,
Feb 4, 2014, 8:24:01 AM2/4/14
to ggp...@googlegroups.com, camackay
I have the same versions of R and ggplot 2, but I am using a Mac:

R version 3.0.2 (2013-09-25)
Platform: x86_64-apple-darwin10.8.0 (64-bit)

locale:
[1] en_CA.UTF-8/en_CA.UTF-8/en_CA.UTF-8/C/en_CA.UTF-8/en_CA.UTF-8


attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base    

other attached packages:
[1] reshape2_1.2.2  ggplot2_0.9.3.1


loaded via a namespace (and not attached):
 [1] colorspace_1.2-4   dichromat_2.0-0    digest_0.6.4       grid_3.0.2         gtable_0.1.2     
 [6] labeling_0.2       MASS_7.3-29        munsell_0.4.2      plyr_1.8           proto_0.3-10     
[11] RColorBrewer_1.0-5 scales_0.2.3       stringr_0.6.2      tools_3.0.2      

Also, I seem to have found a work-around that does relate to fonts as found at this website: http://statacumen.com/teaching/ada1/

The error

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

Polygon edge not found

can be fixed by defining a font each time:
p <- p + theme_bw(base_family = 'Helvetica')
print(p)


When I add base_family='Helvetica' I can get the simplified example I posted earlier as well as my original piece of code to run. I'm still curious as to what may have changed when I updated to the newer versions of R and ggplot2 from the older versions to cause this error, but I'm glad that my code is working now. I'm not really sure how to interpret the traceback output but I've posted it below in case anyone is interested.

> qplot(data=mtcars, mpg, wt, fill=cyl)

Error in grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y,  :
  polygon edge not found
> traceback()
15: grid.Call(L_textBounds, as.graphicsAnnot(x$label), x$x, x$y,
        resolveHJust(x$just, x$hjust), resolveVJust(x$just, x$vjust),
        x$rot, 0)
14: widthDetails.text(x)
13: widthDetails(x)
12: (function (x)
    {
        widthDetails(x)
    })(list(label = "cyl", x = 0, y = 0.5, just = "centre", hjust = 0,
        vjust = 0.5, rot = 0, check.overlap = FALSE, name = "guide.title.text.677",
        gp = list(fontsize = 9.6, col = "black", fontfamily = "",
            lineheight = 0.9, font = 2L), vp = NULL))
11: grid.Call(L_convert, x, as.integer(whatfrom), as.integer(whatto),
        valid.units(unitTo))
10: convertUnit(x, unitTo, "x", "dimension", "x", "dimension", valueOnly = valueOnly)
9: convertWidth(grobWidth(grob.title), "mm")
8: guide_gengrob.colorbar(X[[1L]], ...)
7: FUN(X[[1L]], ...)
6: lapply(gdefs, guide_gengrob, theme)
5: guides_gengrob(gdefs, theme)
4: build_guides(plot$scales, plot$layers, plot$mapping, position,
       theme, plot$guides, plot$labels)
3: ggplot_gtable(data)
2: print.ggplot(list(data = list(mpg = c(21, 21, 22.8, 21.4, 18.7,
   18.1, 14.3, 24.4, 22.8, 19.2, 17.8, 16.4, 17.3, 15.2, 10.4, 10.4,
   14.7, 32.4, 30.4, 33.9, 21.5, 15.5, 15.2, 13.3, 19.2, 27.3, 26,
   30.4, 15.8, 19.7, 15, 21.4), cyl = c(6, 6, 4, 6, 8, 6, 8, 4,
   4, 6, 6, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 8, 8, 8, 8, 4, 4, 4, 8,
   6, 8, 4), disp = c(160, 160, 108, 258, 360, 225, 360, 146.7,
   140.8, 167.6, 167.6, 275.8, 275.8, 275.8, 472, 460, 440, 78.7,
   75.7, 71.1, 120.1, 318, 304, 350, 400, 79, 120.3, 95.1, 351,
   145, 301, 121), hp = c(110, 110, 93, 110, 175, 105, 245, 62,
   95, 123, 123, 180, 180, 180, 205, 215, 230, 66, 52, 65, 97, 150,
   150, 245, 175, 66, 91, 113, 264, 175, 335, 109), drat = c(3.9,
   3.9, 3.85, 3.08, 3.15, 2.76, 3.21, 3.69, 3.92, 3.92, 3.92, 3.07,
   3.07, 3.07, 2.93, 3, 3.23, 4.08, 4.93, 4.22, 3.7, 2.76, 3.15,
   3.73, 3.08, 4.08, 4.43, 3.77, 4.22, 3.62, 3.54, 4.11), wt = c(2.62,
   2.875, 2.32, 3.215, 3.44, 3.46, 3.57, 3.19, 3.15, 3.44, 3.44,
   4.07, 3.73, 3.78, 5.25, 5.424, 5.345, 2.2, 1.615, 1.835, 2.465,
   3.52, 3.435, 3.84, 3.845, 1.935, 2.14, 1.513, 3.17, 2.77, 3.57,
   2.78), qsec = c(16.46, 17.02, 18.61, 19.44, 17.02, 20.22, 15.84,
   20, 22.9, 18.3, 18.9, 17.4, 17.6, 18, 17.98, 17.82, 17.42, 19.47,
   18.52, 19.9, 20.01, 16.87, 17.3, 15.41, 17.05, 18.9, 16.7, 16.9,
   14.5, 15.5, 14.6, 18.6), vs = c(0, 0, 1, 1, 0, 1, 0, 1, 1, 1,
   1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0,
   1), am = c(1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1), gear = c(4, 4,
   4, 3, 3, 3, 3, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 4, 4, 4, 3, 3, 3,
   3, 3, 4, 5, 5, 5, 5, 5, 4), carb = c(4, 4, 1, 1, 2, 1, 4, 2,
   2, 4, 4, 3, 3, 3, 4, 4, 4, 1, 2, 1, 1, 2, 2, 4, 2, 1, 2, 2, 4,
   6, 8, 2)), layers = list(<environment>), scales = <S4 object of class "Scales">,
       mapping = list(fill = cyl, x = mpg, y = wt), theme = list(),
       coordinates = list(limits = list(x = NULL, y = NULL)), facet = list(
           shrink = TRUE), plot_env = <environment>, labels = list(
           fill = "cyl", x = "mpg", y = "wt")))
1: print(list(data = list(mpg = c(21, 21, 22.8, 21.4, 18.7, 18.1,
   14.3, 24.4, 22.8, 19.2, 17.8, 16.4, 17.3, 15.2, 10.4, 10.4, 14.7,
   32.4, 30.4, 33.9, 21.5, 15.5, 15.2, 13.3, 19.2, 27.3, 26, 30.4,
   15.8, 19.7, 15, 21.4), cyl = c(6, 6, 4, 6, 8, 6, 8, 4, 4, 6,
   6, 8, 8, 8, 8, 8, 8, 4, 4, 4, 4, 8, 8, 8, 8, 4, 4, 4, 8, 6, 8,
   4), disp = c(160, 160, 108, 258, 360, 225, 360, 146.7, 140.8,
   167.6, 167.6, 275.8, 275.8, 275.8, 472, 460, 440, 78.7, 75.7,
   71.1, 120.1, 318, 304, 350, 400, 79, 120.3, 95.1, 351, 145, 301,
   121), hp = c(110, 110, 93, 110, 175, 105, 245, 62, 95, 123, 123,
   180, 180, 180, 205, 215, 230, 66, 52, 65, 97, 150, 150, 245,
   175, 66, 91, 113, 264, 175, 335, 109), drat = c(3.9, 3.9, 3.85,
   3.08, 3.15, 2.76, 3.21, 3.69, 3.92, 3.92, 3.92, 3.07, 3.07, 3.07,
   2.93, 3, 3.23, 4.08, 4.93, 4.22, 3.7, 2.76, 3.15, 3.73, 3.08,
   4.08, 4.43, 3.77, 4.22, 3.62, 3.54, 4.11), wt = c(2.62, 2.875,
   2.32, 3.215, 3.44, 3.46, 3.57, 3.19, 3.15, 3.44, 3.44, 4.07,
   3.73, 3.78, 5.25, 5.424, 5.345, 2.2, 1.615, 1.835, 2.465, 3.52,
   3.435, 3.84, 3.845, 1.935, 2.14, 1.513, 3.17, 2.77, 3.57, 2.78
   ), qsec = c(16.46, 17.02, 18.61, 19.44, 17.02, 20.22, 15.84,
   20, 22.9, 18.3, 18.9, 17.4, 17.6, 18, 17.98, 17.82, 17.42, 19.47,
   18.52, 19.9, 20.01, 16.87, 17.3, 15.41, 17.05, 18.9, 16.7, 16.9,
   14.5, 15.5, 14.6, 18.6), vs = c(0, 0, 1, 1, 0, 1, 0, 1, 1, 1,
   1, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 0, 0, 0, 0, 1, 0, 1, 0, 0, 0,
   1), am = c(1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
   1, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1), gear = c(4, 4,
   4, 3, 3, 3, 3, 4, 4, 4, 4, 3, 3, 3, 3, 3, 3, 4, 4, 4, 3, 3, 3,
   3, 3, 4, 5, 5, 5, 5, 5, 4), carb = c(4, 4, 1, 1, 2, 1, 4, 2,
   2, 4, 4, 3, 3, 3, 4, 4, 4, 1, 2, 1, 1, 2, 2, 4, 2, 1, 2, 2, 4,
   6, 8, 2)), layers = list(<environment>), scales = <S4 object of class "Scales">,
       mapping = list(fill = cyl, x = mpg, y = wt), theme = list(),
       coordinates = list(limits = list(x = NULL, y = NULL)), facet = list(
           shrink = TRUE), plot_env = <environment>, labels = list(
           fill = "cyl", x = "mpg", y = "wt")))
>


Thanks for your suggestions and prompt response.


Reply all
Reply to author
Forward
0 new messages