Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in R Programming by (50.2k points)

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

image

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?

1 Answer

0 votes
by (107k 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.

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...