Plotly 3D
- 3D:
scatter, surface, mesh
3D Layout
- 3D Scene: Camera, Aspect Ratio
- 3D Axes: X, Y, Z
- Have to be specified in
scene = list()
3D Axes
p <- plot_ly(data = swiss, x = ~Catholic, y = ~Fertility, z = ~Education, type="scatter3d", mode = "markers")
layout(p,
scene = list(
yaxis = list(
showexponent = "all",
showticklabels = TRUE,
ticksuffix = "y",
color = "black",
titlefont = list(color = "red", family = "Times New Roman", size = 10),
title = "Fertility"
)
))
3D Aspectmode and Camera
p <- plot_ly(data = swiss, x = ~Catholic, y = ~Fertility, z = ~Education, type="scatter3d", mode = "markers")
layout(p,
scene = list(
domain = list(y = c(0,1), x = c(0,1)),
aspectmode = "cube", # (enumerated: "auto" | "cube" | "data" | "manual" )
dragmode = "orbit", # (enumerated: "orbit" | "turntable" | "zoom" | "pan" )
camera = list( # Sets the (x,y,z) components of the 'eye' camera vector. This vector determines the view point about the origin of this scene.
eye = list(x = 1.25, y = 1.25, z = 1.25),
up = list(x = 0, y = 0, z = 1), # Sets the (x,y,z) components of the 'up' camera vector. This vector determines the up direction of this scene with respect to the page. The default is "{x: 0, y: 0, z: 1}" which means that the z axis points up.
# center = list(x = 0, y = 0, z = 1), # Sets the (x,y,z) components of the 'center' camera vector This vector determines the translation (x,y,z) space about the center of this scene. By default, there is no such translation.
#aspectratio = list(x = 1, y = 1, z = 1) ,
hovermode = "closest"
)),
height = 20
)