简体   繁体   中英

R: Interactive 3D plotly scatterplot rgl-style with hover info

I'm using plotly to draw an interactive 3D scatter plot with spheres, eg:

df <- data.frame(x = c(1,3,5), y = c(1,3,5), z = c(1,3,5), size = c(1,3,5))

library(plotly)
plot_ly(df, type = "scatter3d", x = ~x, y = ~y, z = ~z, size = ~size,
    marker = list(symbol = 'circle', sizemode = 'diameter'))

在此处输入图片说明

The problem is: I hate plotly's spheres. I much prefer rgl 's spheres which have a "shine" effect to them, eg:

library(rgl)
spheres3d(x = df$x, y = df$y, z = df$z, radius = 0.8 * sqrt(df$size))

在此处输入图片说明

And I think there's even a way in which rgl objects can be embedded in web page like plotly objects. However they lack the ability to present data on hover and other attractive capabilities of plotly.

Is there a way to get my plotly spheres to have a "shine" effect and look more like rgl's spheres? Or a way to make rgl plots have some of plotly's features especially hove info?

This should be possible with a lot of Javascript programming, since when it's embedded in a web page, rgl is using Javascript for everything. However, there's no built-in support for reacting to mouse movements like that. Within R (using Windows or X11 to display the scene, not a browser) it's probably harder, but the select3d and identify3d functions do related things (though not event-driven).

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