简体   繁体   中英

3d scatter animation in R, plotly

I have a 3D plot in plotly for R that I want to put into a presentation. Is there a way I can animate the 3D space rotating in some way as a.gif or other from R?

I understand how to make the plot, how to rotate it on my own, and how to publish it on RPubs, but can't figure out how to save it out. Example below.

# build dataframe 
df <- data.frame(replicate(3,sample(0:25,50,rep=TRUE)))

# 3d scatterplot
p1 <- plot_ly(df, x = ~X1, y = ~X2, z = ~X3, 
        type = "scatter3d",
        mode = "markers")
p1

Now we have a cool 3D scatterplot in viewer that user can rotate with mouse drags, but I want to save it out to rotate on its own. There is also a 'save to png' button in the viewer, but when I click it, a text box pops up that says "there was a problem saving your image." I'm thinking some kind of loop that saves images out at different viewer angles, then stitches them together? Any ideas appreciated.

I also tried using the orca() command and received the following error:

orca(p1,file="3dplot.png")
Error: The orca command-line utility is required for this functionality.

Not sure what it means.

In the Viewer tab, if you click Export and Save as Web Page... you might get what you want. Remember to use the.html extention

Neither of both options Save to png or orca() are going to work because the save a snapshot of the current angle so you lose the dynamic part.

Best!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM