2

the z3 vector data is produced by prediction from a linear model of x and y so the 3D plot should be a plane. I supplied 4 points from the "corners" of the data ranges for x and y

plotly will only accept a matrix for the z dimension, so I tried a 2X2 for four data points

x3 <- c(25,25,50,50)
y3 <- c(10,80,10,80)
z3[1,1] <- 1030
z3[1,2] <- 1028 
z3[2,1] <- 791
z3[2,2] <- 903

plot the plane

plot_ly(x=x3,y=y3,z=z3)%>% add_surface()  

I get 2 points with x=25, y=80 and 2 with x=25, y=10 but none with x[3:4] or y[3:4]

the attached plot has another layer of points but I did not think adding all that code and data would help.

3D surface plot with incorrect plane rendering: img

How do I decide what dimensions the z data matrix should have based on the number of points I want to plot and the length of the x and y vectors?

Phil H
  • 21
  • 1
  • 5
  • Check this: http://stackoverflow.com/questions/3979240/r-plotting-a-3d-surface-from-x-y-z – Mohit Dec 09 '16 at 07:37
  • 1
    there are some great hints in that thread for other plotting packages but I didn't get any more knowledge about what all types of inputs plotly takes or how it combines vectors for x and y and an array for z. The volcano data set built into r is a two dimensional array of numeric and plots easily with a simple syntax 'code' plot_ly(z=volcano, type="surface") – Phil H Dec 09 '16 at 23:26

0 Answers0