-
Notifications
You must be signed in to change notification settings - Fork 74
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
Hover Misaligned for geom_line_interactive() #248
Comments
Sorry, it seems we activated
|
Hi @davidgohel , thanks for the reply and for the dedication to this awesome package. I tried your suggestion, but I'm getting the same unexpected behavior. For example, hovering over the group 1 line between x=2 and x=4 highlights the group 3 line because that polygon is considered on top of the group 1 polygon. EDIT: Accidentally closed the issue. |
ok, sorry I understand now yes, your analysis is the correct one. |
I also noticed this bug just now when upgrading R version and packages. In my case I was plotting ROC curves and the hovering behaviour was very different from the expected. The only workaround I was able to come up with was to split each line into shorter pieces, since the "hitbox" from each piece becomes much smaller than from the entire line. |
@davidgohel @sigmapi do you have any updates on this issue? As much as I appreciate your package and promote its use, I find this particular issue to severely limit the usefulness of the package when plotting lines and paths. The problem is now further compounded by more recently introduced bugs related to lines - I'm thinking primarily of #299 that I have also experienced. I constructed another example to try to illustrate just how limiting this issue can be. If there are other elements, e.g. points, that end up inside a path's hitbox, their interactive properties can disappear entirely. In this case the path takes the shape of a triangle (together with the x-axis), and it is impossible to interact with the six points that are inside this triangle. library(ggplot2)
library(ggiraph)
# Define ggplot with only points
gg1 <- ggplot(data=data.frame(x=c(0.5, rep(1:3, 2)), y=c(2, rep(c(0.5,1), each=3)))) +
geom_point_interactive(aes(x=x, y=y, data_id="point", tooltip="This is a point")) +
scale_x_continuous(limits=c(0,4)) +
scale_y_continuous(limits=c(0,3)) +
theme_minimal()
# Define ggplot with both points and lines
gg2 <- gg1 +
geom_path_interactive(data=data.frame(x=c(0,2,4), y=c(0,3,0)),
aes(x=x, y=y, data_id="line", tooltip="This is a line (or is it?)"), color="blue")
# Only points: Works as expected
girafe(ggobj=gg1)
# Points and line:
# - Line hover is active inside the entire triangle
# - Points inside the triangle cannot be hovered at all
girafe(ggobj=gg2) I tried to look into the source code and I appreciate that this might not be entirely straightforward to resolve. Nevertheless, I would encourage you to consider this a prioritized issue to fix. From the user perspective, the desired behaviour would be for lines and paths to be treated merely as sets of connected points without considering the area they enclose. (For this we can always use polygons.) Many thanks for a great package and for all the work you have put into it! |
Since updating my packages, I've been getting strange behavior when hovering over lines created by geom_line_interactive(). Lines get the hover effect even when the mouse is far from the line, and sometimes the line won't get the hover effect when the mouse is directly over it. This seems to only be a problem for line geoms (see the code below).
Version numbers:
ggplot2 3.4.0
ggiraph 0.8.5
R 4.2.2
Edit I think I found the issue. The geom_line_interactive() function uses the same "hitbox" as geom_polygon_interactive().
The text was updated successfully, but these errors were encountered: