Skip to content

Instantly share code, notes, and snippets.

Created August 10, 2018 22:00
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save dpseidel/322db7110b8590d77ba20f3db8f399fc to your computer and use it in GitHub Desktop.
debugging the "polygon edge not found" error
#### This is a script useful for debugging the very tricky, intermittent,
#### "polygon edge not found" error triggered in grid when using the RstudioGD and quartz devices
#system info
getOption("bitmapType") # this needs to be quartz
getOption("device") # this needs to be RStudioGD
# blank plot
blank_base <- ggplot(data.frame(), aes(1, 1)) +
axis.title.y = element_blank(),
axis.title.x = element_blank(),
axis.text.y = element_blank(),
axis.ticks = element_blank(),
panel.background = element_blank(),
panel.grid = element_blank()
# with "graticule" labels matching output of sf::st_graticule
p <- blank_base + scale_x_continuous(labels = c(
expr(160 * degree * W), expr(140 * degree * W),
expr(120 * degree * W), expr(100 * degree * W),
expr(0 * degree * W)
# with superscripts -- ala scales::math_format. higher failure rate typically
q <- blank_base + scale_x_continuous(labels = c(
expr(10 ^ 1), expr(10 ^ 2),
expr(10 ^ 3), expr(10 ^ 4),
expr(10 ^ 5)
# Simulate it... function
plot_ok <- function(p) {
}, error = function(e) {
(sim <- replicate(50, plot_ok(q)))
sum(sim) / 50
Copy link

dpseidel commented Aug 29, 2018

@pmur002 I'm so sorry for the delay, I only saw your message now. This works with either version of ggplot, 3.0.0 (on CRAN) or; I have run it on both. Also, as of version 3.0.0 ggplot2 imports and reexports expr from rlang so you shouldn't need any additional dependencies. Please let me know if you need any other clarification.

Copy link

pmur002 commented Sep 7, 2018

Thanks. I can now run this. Of course, on my setup this does not fail (yet), but at least I can run it to check! :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment