-
Notifications
You must be signed in to change notification settings - Fork 309
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
broken line at end of animation #502
Comments
The first issue appears to be caused by the call to Line 76 in b46d1ff
The data is in the correct order prior to this, but after this call, the rows in each frame are sorted in the opposite order to what the should be. In this case, since the movement in the x direction is negative, the rows should be sorted in descending order. However, this function sorts them in ascending order so the order of the points is wrong in each frame. The only workarounds that I see is to make as many frames as there are rows in the data (obviously with thousands of rows this would be prohibitive) or to detect the order before calling the function, then fix it after calling. However, I don't know enough about the internal workings of Edited to add: To confirm this is the case, I did the following:
data <- lapply(data,
function(el){
el[order(el$x, decreasing = TRUE),]
})
|
If you're reading this and facing a similar issue to mine, the code below (or something like it) demonstrates a temporary work-around with version 1.0.9 and 1.0.9.9000 (line numbers in the Basically, it inserts code into the # Define code to be inserted
e <- quote(data <- lapply(data, function(el){
if(is.null(el$x)) # Assuming x is the aesthetic that needs sorted
return(el)
el[order(el$x, decreasing = TRUE),] # Sort the aesthetic correctly
})
)
# Insert the code
trace(gganimate:::ggplot_build.gganim, e, at = 31, print = FALSE)
## RENDER THE ANIMATION HERE
# ...
##
# Revert to the gganimate's version of the function
untrace(gganimate:::ggplot_build.gganim) Thanks to G. Grothendieck on Stack Overflow for suggesting |
When running the following code, I should get a smooth line starting from
x=.5
tracing tox=0
, monotonically increasing.The plain
ggplot
shows this clearly:However, the end of the resulting animation appears to be broken:
This may be related to #486. However, I did try version 1.0.7 and the dev version (1.0.9.9) and they all seemed to show the issue, so I'm not sure.
Edited to remove second apparently unrelated issue
The text was updated successfully, but these errors were encountered: