How to find out index in plotly in R

1 view

On this website, there are lots of 3D figures. For example

library(plotly)

fig <- plot_ly(

x = c(0, 1, 2, 0),

y = c(0, 0, 1, 2),

z = c(0, 2, 0, 1),

i = c(0, 0, 0, 1),

j = c(1, 2, 3, 2),

k = c(2, 3, 1, 3),

facecolor = toRGB(viridisLite::viridis(4))

)

fig

How can I find out this:

i = c(0, 0, 0, 1),

j = c(1, 2, 3, 2),

k = c(2, 3, 1, 3)

I want to build interactive plots using plotly. How can I do that?

by (90.3k points)

Let me tell you that these x, y and z are the vectors:

x = c(0, 1, 2, 0),

y = c(0, 0, 1, 2),

z = c(0, 2, 0, 1),

And these are representing four points (0,0,0), (1,0,2), (2,1,0), (0,2,1). They are indexed by 0, 1, 2, 3 respectively.

The i, j, k vectors represents four triangles:

i = c(0, 0, 0, 1),

j = c(1, 2, 3, 2),

k = c(2, 3, 1, 3)

The first one is denoted by (0,1,2). This means the points of the corresponding triangle are the points indexed by these 0, 1, 2 values. The second one, (0,2,3), is the triangle whose points are the points indexed by 0, 2, 3. Etc.

If you want to know more about R then do check out the R programming course.