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 | |
library(ggplot2) | |
#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)) + | |
theme( | |
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) { | |
tryCatch({ | |
print(p) | |
TRUE | |
}, error = function(e) { | |
#print(e) | |
return(FALSE) | |
} | |
) | |
} | |
(sim <- replicate(50, plot_ok(q))) | |
sum(sim) / 50 |
This comment has been minimized.
This comment has been minimized.
@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 3.0.0.9000; I have run it on both. Also, as of version 3.0.0 ggplot2 imports and reexports |
This comment has been minimized.
This comment has been minimized.
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
This comment has been minimized.
Thanks for this. I wanted to run it myself to make sure that it does not fail on my setup, but there is at least one dependency missing (e.g., 'rlang' for expr() ?). Also, is this designed for ggplot2 development version or the CRAN version? Thanks for any clarificaitons