You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
ggplotly fails with an empty layer of geom_vline #1947
ggplotly fails when there is a geom_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 then ggplotly fails with the following error message:
Fehler in fix.by(by.y, y) : 'by' must specify a uniquely valid column
Minimal example:
do_plot<-function(xintercepts) {
ggplot(mtcars, aes(mpg, carb)) + geom_point() +
geom_vline(xintercept=xintercepts)
}
plotly::ggplotly(do_plot(23)) # works fineplotly::ggplotly(do_plot(c(15, 25))) # works fineplotly::ggplotly(do_plot(numeric())) # produces error (but works without call to ggplotly)
I have the same issue; ggplot2 works well as is but when passed to plotly it fails - expected behaviour is no vertical line drawn but the rest of the plot yes.
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 tryCatch or return some default/empty object? @cpsievert
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.
Browse[1]> lay[c("PANEL", y)]
PANEL y
1 1 5354.531
2 1 12343.073
Browse[1]> data
[1] group
<0 rows> (or 0-length row.names)
Note for consistency I believe that to_basic.GeomHline will have to be modified as well to allow for non-existing lines.
Activity
dereckmezquita commentedon Apr 9, 2023
I have the same issue;
ggplot2works well as is but when passed toplotlyit fails - expected behaviour is no vertical line drawn but the rest of the plot yes.Here is my traceback; I'm using
shiny+plotly:dereckmezquita commentedon Apr 9, 2023
I checked out the source code I believe this is where the failure is occurring; I will tinker with this today a bit:
dereckmezquita commentedon Apr 9, 2023
This function attempts to merge these two objects:
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
tryCatchor return some default/empty object? @cpsievertIf 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
to_basic.GeomHlinewill have to be modified as well to allow for non-existing lines.