3D plots
3-dimensional plots are beautiful. Very often, they create a good impression with their audience, but the truth is that they are not the best type of graphic to use. To plot a 3D graphic on a 2D space, such as on a computer screen or on paper, the third dimension will have to simulate depth that does not exist. It is not recommended that you plot in 3D very often, as in general, a good old 2D plot will be the simplest and best option.
Sometimes, though, looking at 3D plots can be useful. Cases such as surface graphics, which can represent the surface of a given place, such as a mountain, can be interesting.
3D graphics can be created using the plotly library in R (loaded with library(plotly)
). Let’s create a random surface and plot it. The surface graphics require the input data to be a matrix, thus we are creating one and then using the plot_ly()
function, passing the z= ~surface
argument to it to indicate that we want a 3D graphic. Remember that x and y are...