#Generate 3D scatter plot (x,y,z) with best fit plane
plot_ly() %>% #Using pipes here to chain everything together
#This will generate our scatter points in 3D, Color for ASU
add_markers(x = x, y = y, z = z, marker = list(color = 'maroon'),
name = "Test Subjects") %>%
#Matrix function converts the z values to match the dimensions
add_surface(x = x2, y = y2,
z = matrix(graph$z, nrow = 50, ncol = 50),
colorscale = list(c(0, 1), c('gold', 'gold')),
opacity = 0.6,
showscale = FALSE, #TOOK SO LONG TO FIND this code
name = "Best Fit Plane") %>%
#Final section sets the title, and configures the 3D axis
layout(title = "3D Scatter Plot with Best Fit Plane",
scene = list(
xaxis = list(title = "Blinks Per Minute"),
yaxis = list(title = "Beats Per Minute"),
zaxis = list(title = "Stress Level [%]")
))