-
Notifications
You must be signed in to change notification settings - Fork 633
ggplotly
fails with an empty layer of geom_vline
#1947
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I have the same issue; Here is my traceback; I'm using traceback()
|
I checked out the source code I believe this is where the failure is occurring; I will tinker with this today a bit: #' @export
to_basic.GeomVline <- function(data, prestats_data, layout, params, p, ...) {
# ugh, we can't trust the group here
data$group <- do.call(paste,
data[!grepl("group", names(data)) & !vapply(data, anyNA, logical(1))]
)
y <- if (inherits(p$coordinates, "CoordFlip")) "x" else "y"
lay <- tidyr::pivot_longer(
data = layout$layout, cols = paste0(y, c("_min", "_max")), values_to = y, names_to = "variable"
)
lay <- as.data.frame(lay)
data <- merge(lay[c("PANEL", y)], data, by = "PANEL")
data[["y"]] <- data[[y]]
data[["x"]] <- data$xintercept
prefix_class(data, c("GeomVline", "GeomPath"))
} |
This function attempts to merge these two objects: data <- merge(lay[c("PANEL", y)], data, by = "PANEL") I am browsing here and see that the data object is empty, and thus it cannot be merged; this will obviously throw an error. Indeed, this is the source of the error. Can someone tell me the expected behaviour here; what should we do? A If someone can help me understand the convention of what to return here, I'll fix it and submit a pull request for this today.
Note for consistency I believe that |
ggplotly
fails when there is ageom_vline
-layer that does not contain any lines. For me, this happens in a setting where I have a function that computes a set of x-values at which I want to have vertical lines. Sometimes it happens that no vertical line is needed, and thenggplotly
fails with the following error message:Minimal example:
The text was updated successfully, but these errors were encountered: