Open PavelBal opened 10 months ago
I think I encountered this issue before, if I recall it was due to log scale conversion and usage of annotation_logticks
when there were actually no tick to display. I thought is was fixed at some point, but maybe not in the end.
Here is a sample example
library(ggplot2)
ggplot(
data = data.frame(x = c(0.083, 0.083), y = c(13.61104, 13.61104)),
mapping = aes(x,y)
) +
geom_point() +
scale_x_log10() +
scale_y_log10() +
annotation_logticks()
#> Error in `annotation_logticks()`:
#> ! Problem while converting geom to grob.
#> ℹ Error occurred in the 2nd layer.
#> Caused by error in `unit()`:
#> ! 'x' and 'units' must have length > 0
#> Backtrace:
#> ▆
#> 1. ├─base::tryCatch(...)
#> 2. │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#> 3. │ ├─base (local) tryCatchOne(...)
#> 4. │ │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 5. │ └─base (local) tryCatchList(expr, names[-nh], parentenv, handlers[-nh])
#> 6. │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 7. │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 8. ├─base::withCallingHandlers(...)
#> 9. ├─base::saveRDS(...)
#> 10. ├─base::do.call(...)
#> 11. ├─base (local) `<fn>`(...)
#> 12. ├─global `<fn>`(input = base::quote("tweed-barb_reprex.R"))
#> 13. │ └─rmarkdown::render(input, quiet = TRUE, envir = globalenv(), encoding = "UTF-8")
#> 14. │ └─knitr::knit(knit_input, knit_output, envir = envir, quiet = quiet)
#> 15. │ └─knitr:::process_file(text, output)
#> 16. │ ├─base::withCallingHandlers(...)
#> 17. │ ├─base::withCallingHandlers(...)
#> 18. │ ├─knitr:::process_group(group)
#> 19. │ └─knitr:::process_group.block(group)
#> 20. │ └─knitr:::call_block(x)
#> 21. │ └─knitr:::block_exec(params)
#> 22. │ └─knitr:::eng_r(options)
#> 23. │ ├─knitr:::in_input_dir(...)
#> 24. │ │ └─knitr:::in_dir(input_dir(), expr)
#> 25. │ └─knitr (local) evaluate(...)
#> 26. │ └─evaluate::evaluate(...)
#> 27. │ └─evaluate:::evaluate_call(...)
#> 28. │ ├─evaluate (local) handle(...)
#> 29. │ │ └─base::try(f, silent = TRUE)
#> 30. │ │ └─base::tryCatch(...)
#> 31. │ │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#> 32. │ │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 33. │ │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 34. │ ├─base::withCallingHandlers(...)
#> 35. │ ├─base::withVisible(value_fun(ev$value, ev$visible))
#> 36. │ └─knitr (local) value_fun(ev$value, ev$visible)
#> 37. │ └─knitr (local) fun(x, options = options)
#> 38. │ ├─base::withVisible(knit_print(x, ...))
#> 39. │ ├─knitr::knit_print(x, ...)
#> 40. │ └─knitr:::knit_print.default(x, ...)
#> 41. │ └─evaluate (local) normal_print(x)
#> 42. │ ├─base::print(x)
#> 43. │ └─ggplot2:::print.ggplot(x)
#> 44. │ ├─ggplot2::ggplot_gtable(data)
#> 45. │ └─ggplot2:::ggplot_gtable.ggplot_built(data)
#> 46. │ └─ggplot2:::by_layer(...)
#> 47. │ ├─rlang::try_fetch(...)
#> 48. │ │ ├─base::tryCatch(...)
#> 49. │ │ │ └─base (local) tryCatchList(expr, classes, parentenv, handlers)
#> 50. │ │ │ └─base (local) tryCatchOne(expr, names, parentenv, handlers[[1L]])
#> 51. │ │ │ └─base (local) doTryCatch(return(expr), name, parentenv, handler)
#> 52. │ │ └─base::withCallingHandlers(...)
#> 53. │ └─ggplot2 (local) f(l = layers[[i]], d = data[[i]])
#> 54. │ └─l$draw_geom(d, layout)
#> 55. │ └─ggplot2 (local) draw_geom(..., self = self)
#> 56. │ └─self$geom$draw_layer(...)
#> 57. │ └─ggplot2 (local) draw_layer(..., self = self)
#> 58. │ └─base::lapply(...)
#> 59. │ └─ggplot2 (local) FUN(X[[i]], ...)
#> 60. │ ├─rlang::inject(self$draw_panel(data, panel_params, coord, !!!params))
#> 61. │ └─self$draw_panel(...)
#> 62. │ └─ggplot2 (local) draw_panel(...)
#> 63. │ ├─base::with(...)
#> 64. │ └─base::with.default(...)
#> 65. │ └─base::eval(substitute(expr), data, enclos = parent.frame())
#> 66. │ └─base::eval(substitute(expr), data, enclos = parent.frame())
#> 67. │ ├─grid::segmentsGrob(...)
#> 68. │ │ └─grid::is.unit(x0)
#> 69. │ └─grid::unit(yticks$start, "cm")
#> 70. │ └─base::stop("'x' and 'units' must have length > 0")
#> 71. └─base::.handleSimpleError(...)
#> 72. └─rlang (local) h(simpleError(msg, call))
#> 73. └─handlers[[1L]](cnd)
#> 74. └─cli::cli_abort(...)
#> 75. └─rlang::abort(...)
Created on 2023-10-18 with reprex v2.0.2
Happens here https://github.com/Open-Systems-Pharmacology/TLF-Library/blob/d206f8519891df0e3717c91aa4e796903812e3d0/R/aaa-utilities.R#L100