How to do it...

Constructing three-dimensional plots with plotly can be done using the following steps:

  1. Set up the data objects:
library(plotly)

d <- data.frame(
  x <- seq(1,10, by = 0.5),
  y <- seq(1,10, by = 0.5)
)

z <- matrix(rnorm(length(d$x) * length(d$y) ), nrow = length(d$x), ncol = length(d$y))
  1. Create the basic surface plot:
plot_ly(d, x = ~x , y = ~y, z = ~z) %>% 
  add_surface()
  1. Add a reactive contour plot layer:
plot_ly(d, x = ~x , y = ~y, z = ~z) %>% 
  add_surface(
    contours = list(
    z = list(
      show=TRUE,
      usecolormap=TRUE,
      highlightcolor="#ff0000",
      project=list(z=TRUE)
      )
    )
  )
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.171.137