treeplot not working

Open
#234 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
1-2 days
Newbie friendliness
35/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
r

Research direction

No source file or test is named. Start by reproducing treeplot with the reported R v4.1 context, then inspect the treeplot rendering path and the third geom_segment2 layer shown in the traceback. Done means treeplot renders without the zero-length lwd error, with a regression test covering the failure.

Written by the indexing model from the issue text.

Description

Hello,

treeplot used to work fine for me (R v4.1) but now it is giving me this error. Could you help?

ERROR while rich displaying an object: Error in geom_segment2():
! Problem while converting geom to grob.
ℹ Error occurred in the 3rd layer.
Caused by error in check.length():
! 'gpar' element 'lwd' must not be length 0

Traceback:

  1. tryCatch(withCallingHandlers({
    . if (!mime %in% names(repr::mime2repr))
    . stop("No repr_* for mimetype ", mime, " in repr::mime2repr")
    . rpr <- repr::mime2repr[mime]
    . if (is.null(rpr))
    . return(NULL)
    . prepare_content(is.raw(rpr), rpr)
    . }, error = error_handler), error = outer_handler)
  2. tryCatchList(expr, classes, parentenv, handlers)
  3. tryCatchOne(expr, names, parentenv, handlers[[1L]])
  4. doTryCatch(return(expr), name, parentenv, handler)
  5. withCallingHandlers({
    . if (!mime %in% names(repr::mime2repr))
    . stop("No repr_* for mimetype ", mime, " in repr::mime2repr")
    . rpr <- repr::mime2repr[mime]
    . if (is.null(rpr))
    . return(NULL)
    . prepare_content(is.raw(rpr), rpr)
    . }, error = error_handler)
  6. repr::mime2repr[mime]
  7. repr_text.default(obj)
  8. paste(capture.output(print(obj)), collapse = "\n")
  9. capture.output(print(obj))
  10. withVisible(...elt(i))
  11. print(obj)
  12. print.ggplot(obj)
  13. ggplot_gtable(data)
  14. ggplot_gtable.ggplot_built(data)
  15. by_layer(function(l, d) l$draw_geom(d, layout), plot$layers,
    . data, "converting geom to grob")
  16. try_fetch(for (i in seq_along(data)) {
    . out[[i]] <- f(l = layers[[i]], d = data[[i]])
    . }, error = function(cnd) {
    . cli::cli_abort(c("Problem while {step}.", i = "Error occurred in the {ordinal(i)} layer."),
    . call = layers[[i]]$constructor, parent = cnd)
    . })
  17. tryCatch(withCallingHandlers(expr, condition = function(cnd) {
    . {
    . .handler_frame. <- TRUE
    . .setup_frame. <- frame
    . if (inherits(cnd, "message")) {
    . except <- c("warning", "error")
    . }
    . else if (inherits(cnd, "warning")) {
    . except <- "error"
    . }
    . else {
    . except <- ""
    . }
    . }
    . while (!is_null(cnd)) {
    . if (inherits(cnd, "error")) {
    . out <- handlers[1L]
    . if (!inherits(out, "rlang_zap"))
    . throw(out)
    . }
    . inherit <- .subset2(.subset2(cnd, "rlang"), "inherit")
    . if (is_false(inherit)) {
    . return()
    . }
    . cnd <- .subset2(cnd, "parent")
    . }
    . }), stackOverflowError = handlers[[1L]])
  18. tryCatchList(expr, classes, parentenv, handlers)
  19. tryCatchOne(expr, names, parentenv, handlers[[1L]])
  20. doTryCatch(return(expr), name, parentenv, handler)
  21. withCallingHandlers(expr, condition = function(cnd) {
    . {
    . .handler_frame. <- TRUE
    . .setup_frame. <- frame
    . if (inherits(cnd, "message")) {
    . except <- c("warning", "error")
    . }
    . else if (inherits(cnd, "warning")) {
    . except <- "error"
    . }
    . else {
    . except <- ""
    . }
    . }
    . while (!is_null(cnd)) {
    . if (inherits(cnd, "error")) {
    . out <- handlers[1L]
    . if (!inherits(out, "rlang_zap"))
    . throw(out)
    . }
    . inherit <- .subset2(.subset2(cnd, "rlang"), "inherit")
    . if (is_false(inherit)) {
    . return()
    . }
    . cnd <- .subset2(cnd, "parent")
    . }
    . })
  22. f(l = layers[[i]], d = data[[i]])
  23. l$draw_geom(d, layout)
  24. draw_geom(..., self = self)
  25. self$geom$draw_layer(data, self$computed_geom_params, layout,
    . layout$coord)
  26. draw_layer(..., self = self)
  27. lapply(split(data, data$PANEL), function(data) {
    . if (empty(data))
    . return(zeroGrob())
    . panel_params <- layout$panel_params[[data$PANEL[1]]]
    . inject(self$draw_panel(data, panel_params, coord, !!!params))
    . })
  28. FUN(X[[i]], ...)
  29. inject(self$draw_panel(data, panel_params, coord, !!!params))
  30. self$draw_panel(data, panel_params, coord, arrow = NULL, lineend = "butt",
    . na.rm = FALSE, nudge_x = 0.432898555929542)
  31. draw_panel(...)
  32. grid::segmentsGrob(data$x, data$y, data$xend, data$yend, default.units = "native",
    . gp = gpar(col = alpha(data$colour, data$alpha), fill = alpha(arrow.fill,
    . data$alpha), lwd = data$size * ggplot2::.pt, lty = data$linetype,
    . lineend = lineend, linejoin = linejoin), arrow = arrow)
  33. grob(x0 = x0, y0 = y0, x1 = x1, y1 = y1, arrow = arrow, name = name,
    . gp = gp, vp = vp, cl = "segments")
  34. gpar(col = alpha(data$colour, data$alpha), fill = alpha(arrow.fill,
    . data$alpha), lwd = data$size * ggplot2::.pt, lty = data$linetype,
    . lineend = lineend, linejoin = linejoin)
  35. validGP(list(...))
  36. numnotnull("lwd")
  37. check.length(gparname)
  38. stop(gettextf("'gpar' element '%s' must not be length 0", gparname),
    . domain = NA)
  39. .handleSimpleError(function (cnd)
    . {
    . {
    . .handler_frame. <- TRUE
    . .setup_frame. <- frame
    . if (inherits(cnd, "message")) {
    . except <- c("warning", "error")
    . }
    . else if (inherits(cnd, "warning")) {
    . except <- "error"
    . }
    . else {
    . except <- ""
    . }
    . }
    . while (!is_null(cnd)) {
    . if (inherits(cnd, "error")) {
    . out <- handlers[1L]
    . if (!inherits(out, "rlang_zap"))
    . throw(out)
    . }
    . inherit <- .subset2(.subset2(cnd, "rlang"), "inherit")
    . if (is_false(inherit)) {
    . return()
    . }
    . cnd <- .subset2(cnd, "parent")
    . }
    . }, "'gpar' element 'lwd' must not be length 0", base::quote(check.length(gparname)))
  40. h(simpleError(msg, call))
  41. handlers[1L]
  42. cli::cli_abort(c("Problem while {step}.", i = "Error occurred in the {ordinal(i)} layer."),
    . call = layers[[i]]$constructor, parent = cnd)
  43. rlang::abort(message, ..., call = call, use_cli_format = TRUE,
    . .frame = .frame)
  44. signal_abort(cnd, .file)
Dominant language
R
Stars
260
Forks
75
PR merge metrics
No merged PRs in 30d

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from YuLab-SMU/enrichplot

All issues in YuLab-SMU/enrichplot

Similar issues

More R issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.