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
I wasn't sure if this should be posted under ggraph, tweenr, or maybe even gganimate. This issue stems from the geometry class in ggraph so I posted here. I figure since all three have the same (great) author and maintainer, it could be moved if it's more appropriate elsewhere.
In short when I try to animate a ggraph, it doesn't work if I use the start_cap and/or end_cap aesthetics. Here is an example:
library(tidygraph)
library(ggraph)
library(gganimate)
library(purrr)
baseG <-
# create set of n-complete graphs to transition through
seq(3,7) %>%
map(
~create_complete(.x) %N>%
mutate(group = .x) %E>%
mutate(group = .x)
) %>%
bind_graphs() %>%
# build out common base to ggraph, gganim
ggraph(layout = "kk") +
geom_node_point(
aes(color = group, size = 3),
show.legend = FALSE
) +
theme_void() +
transition_states(group) + enter_fade() + exit_fade()
# adding edges successfully renders
animate(baseG + geom_edge_link())
# adding edges using aes with geometry class results in error
rlang::with_abort(
animate(
baseG + geom_edge_link(
aes(start_cap = circle(3, "mm"), end_cap = circle(3, "mm"))
)
)
)
The error message from the final expression is Error: Only possible to insert geometries.
I dug into it a bit. Essentially what appears to be happening is the geometry columns gets mistaken for character columns in tweenr::tween_state. The data coming from ggraph has columns start_cap and end_cap which are of class geometry. The non-exported function col_classes returns their classes, and consequently the columns in tweendata, as character. When trying to rbind the tween data with to and from, the replacement function [<-.geometry is ultimately called and throws the error.
Ultimately, the error is generated by a call similar to
but I would say the error stems from triggering the wrong interpolation.
I wouldn't consider this a major bug since it can still be animated without using the caps. It just looks, to use your word, "Ugh" especially when you add in arrows to the edges.
Also, thank you for all the work you do on these packages and the rest of the R visualization stack!
The text was updated successfully, but these errors were encountered:
I wasn't sure if this should be posted under
ggraph
,tweenr
, or maybe evengganimate
. This issue stems from thegeometry
class inggraph
so I posted here. I figure since all three have the same (great) author and maintainer, it could be moved if it's more appropriate elsewhere.In short when I try to animate a
ggraph
, it doesn't work if I use thestart_cap
and/orend_cap
aesthetics. Here is an example:The error message from the final expression is
Error: Only possible to insert geometries
.I dug into it a bit. Essentially what appears to be happening is the geometry columns gets mistaken for character columns in
tweenr::tween_state
. The data coming fromggraph
has columnsstart_cap
andend_cap
which are of class geometry. The non-exported functioncol_classes
returns their classes, and consequently the columns intweendata
, as character. When trying torbind
the tween data withto
andfrom
, the replacement function[<-.geometry
is ultimately called and throws the error.Ultimately, the error is generated by a call similar to
but I would say the error stems from triggering the wrong interpolation.
I wouldn't consider this a major bug since it can still be animated without using the caps. It just looks, to use your word, "Ugh" especially when you add in arrows to the edges.
Also, thank you for all the work you do on these packages and the rest of the R visualization stack!
The text was updated successfully, but these errors were encountered: