Here is how we design a 3 dimensional plot with plotly:
- To begin with, have your data created using MASS::kde2d():
> cars_d <- MASS::kde2d(cars$speed, cars$dist, n =50)
- Call plot_ly() and use add_surface() to create a 3D surface:
> library(plotly)> plot_ly(x = cars_d$x, y = cars_d$y, z = cars_d$z) %>% add_surface()
A snapshot from the original output can be seen at the following image (Figure 8.12):
Let's see how the cards are playing.